@gravity-ui/date-components 3.4.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) 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 +2 -1
  139. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js +33 -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/utils.d.ts +2 -2
  158. package/dist/cjs/components/RelativeRangeDatePicker/utils.js +32 -9
  159. package/dist/cjs/components/RelativeRangeDatePicker/utils.js.map +1 -1
  160. package/dist/cjs/components/utils/constants.d.ts +2 -0
  161. package/dist/cjs/components/utils/constants.js +7 -1
  162. package/dist/cjs/components/utils/constants.js.map +1 -1
  163. package/dist/cjs/components/utils/dates.d.ts +6 -1
  164. package/dist/cjs/components/utils/dates.js +6 -1
  165. package/dist/cjs/components/utils/dates.js.map +1 -1
  166. package/dist/cjs/components/utils/filterDOMProps.js +1 -1
  167. package/dist/cjs/components/utils/filterDOMProps.js.map +1 -1
  168. package/dist/cjs/components/utils/mergeProps.js +1 -1
  169. package/dist/cjs/components/utils/mergeProps.js.map +1 -1
  170. package/dist/cjs/components/utils/validation/datePicker.js +1 -1
  171. package/dist/cjs/components/utils/validation/datePicker.js.map +1 -1
  172. package/dist/cjs/components/utils/validation/i18n/ru.json +2 -2
  173. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.d.ts +7 -11
  174. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.js +6 -1
  175. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.js.map +1 -1
  176. package/dist/cjs/hooks/useEventHandler.js +1 -2
  177. package/dist/cjs/hooks/useEventHandler.js.map +1 -1
  178. package/dist/cjs/hooks/useMove.d.ts +2 -2
  179. package/dist/cjs/hooks/useMove.js +6 -9
  180. package/dist/cjs/hooks/useMove.js.map +1 -1
  181. package/dist/cjs/hooks/useResizeObserver.js +1 -1
  182. package/dist/cjs/hooks/useResizeObserver.js.map +1 -1
  183. package/dist/cjs/package.json +1 -1
  184. package/dist/docs/INDEX.md +131 -0
  185. package/dist/docs/components/Calendar.md +125 -0
  186. package/dist/docs/components/DateField.md +206 -0
  187. package/dist/docs/components/DatePicker.md +194 -0
  188. package/dist/docs/components/RangeCalendar.md +125 -0
  189. package/dist/docs/components/RelativeDateField.md +73 -0
  190. package/dist/docs/components/RelativeDatePicker.md +59 -0
  191. package/dist/esm/components/Calendar/Calendar.d.ts +6 -2
  192. package/dist/esm/components/Calendar/Calendar.js +1 -1
  193. package/dist/esm/components/Calendar/Calendar.js.map +1 -1
  194. package/dist/esm/components/CalendarView/Calendar.css +3 -0
  195. package/dist/esm/components/CalendarView/Calendar.css.map +1 -1
  196. package/dist/esm/components/CalendarView/CalendarView.d.ts +2 -1
  197. package/dist/esm/components/CalendarView/CalendarView.js +8 -8
  198. package/dist/esm/components/CalendarView/CalendarView.js.map +1 -1
  199. package/dist/esm/components/CalendarView/hooks/types.d.ts +5 -3
  200. package/dist/esm/components/CalendarView/hooks/types.js.map +1 -1
  201. package/dist/esm/components/CalendarView/hooks/useCalendarCellProps.js +1 -2
  202. package/dist/esm/components/CalendarView/hooks/useCalendarCellProps.js.map +1 -1
  203. package/dist/esm/components/CalendarView/hooks/useCalendarGridProps.js +10 -3
  204. package/dist/esm/components/CalendarView/hooks/useCalendarGridProps.js.map +1 -1
  205. package/dist/esm/components/CalendarView/hooks/useCalendarProps.js +7 -1
  206. package/dist/esm/components/CalendarView/hooks/useCalendarProps.js.map +1 -1
  207. package/dist/esm/components/CalendarView/hooks/useCalendarState.d.ts +5 -3
  208. package/dist/esm/components/CalendarView/hooks/useCalendarState.js +74 -30
  209. package/dist/esm/components/CalendarView/hooks/useCalendarState.js.map +1 -1
  210. package/dist/esm/components/CalendarView/hooks/useRangeCalendarState.js +16 -10
  211. package/dist/esm/components/CalendarView/hooks/useRangeCalendarState.js.map +1 -1
  212. package/dist/esm/components/DateField/DateField.d.ts +1 -1
  213. package/dist/esm/components/DateField/DateField.js +6 -18
  214. package/dist/esm/components/DateField/DateField.js.map +1 -1
  215. package/dist/esm/components/DateField/IncompleteDate.d.ts +28 -0
  216. package/dist/esm/components/DateField/IncompleteDate.js +112 -0
  217. package/dist/esm/components/DateField/IncompleteDate.js.map +1 -0
  218. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.d.ts +34 -68
  219. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.js +17 -248
  220. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.js.map +1 -1
  221. package/dist/esm/components/DateField/hooks/useDateFieldProps.d.ts +2 -0
  222. package/dist/esm/components/DateField/hooks/useDateFieldProps.js +250 -54
  223. package/dist/esm/components/DateField/hooks/useDateFieldProps.js.map +1 -1
  224. package/dist/esm/components/DateField/hooks/useDateFieldState.d.ts +20 -2
  225. package/dist/esm/components/DateField/hooks/useDateFieldState.js +85 -119
  226. package/dist/esm/components/DateField/hooks/useDateFieldState.js.map +1 -1
  227. package/dist/esm/components/DateField/hooks/useFocusManager.d.ts +29 -0
  228. package/dist/esm/components/DateField/hooks/useFocusManager.js +112 -0
  229. package/dist/esm/components/DateField/hooks/useFocusManager.js.map +1 -0
  230. package/dist/esm/components/{RangeDateField → DateField}/hooks/useRangeDateFieldState.d.ts +1 -1
  231. package/dist/esm/components/DateField/hooks/useRangeDateFieldState.js +232 -0
  232. package/dist/esm/components/DateField/hooks/useRangeDateFieldState.js.map +1 -0
  233. package/dist/esm/components/DateField/i18n/ru.json +1 -1
  234. package/dist/esm/components/DateField/index.d.ts +2 -1
  235. package/dist/esm/components/DateField/index.js +1 -1
  236. package/dist/esm/components/DateField/index.js.map +1 -1
  237. package/dist/esm/components/DateField/types.d.ts +2 -22
  238. package/dist/esm/components/DateField/types.js.map +1 -1
  239. package/dist/esm/components/DateField/utils.d.ts +21 -34
  240. package/dist/esm/components/DateField/utils.js +179 -125
  241. package/dist/esm/components/DateField/utils.js.map +1 -1
  242. package/dist/esm/components/DatePicker/DatePicker.d.ts +3 -3
  243. package/dist/esm/components/DatePicker/DatePicker.js +3 -5
  244. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  245. package/dist/esm/components/DatePicker/MobileCalendar.d.ts +1 -1
  246. package/dist/esm/components/DatePicker/MobileCalendar.js +3 -5
  247. package/dist/esm/components/DatePicker/MobileCalendar.js.map +1 -1
  248. package/dist/esm/components/DatePicker/StubButton.d.ts +1 -1
  249. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.d.ts +1 -1
  250. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.js +15 -6
  251. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.js.map +1 -1
  252. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.d.ts +2 -2
  253. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.js +30 -18
  254. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.js.map +1 -1
  255. package/dist/esm/components/HiddenInput/HiddenInput.d.ts +2 -5
  256. package/dist/esm/components/HiddenInput/HiddenInput.js +3 -4
  257. package/dist/esm/components/HiddenInput/HiddenInput.js.map +1 -1
  258. package/dist/esm/components/RangeCalendar/RangeCalendar.d.ts +2 -2
  259. package/dist/esm/components/RangeCalendar/RangeCalendar.js +2 -3
  260. package/dist/esm/components/RangeCalendar/RangeCalendar.js.map +1 -1
  261. package/dist/esm/components/RangeDateField/RangeDateField.d.ts +1 -1
  262. package/dist/esm/components/RangeDateField/RangeDateField.js +7 -20
  263. package/dist/esm/components/RangeDateField/RangeDateField.js.map +1 -1
  264. package/dist/esm/components/RangeDateField/index.d.ts +0 -1
  265. package/dist/esm/components/RangeDateField/index.js +0 -1
  266. package/dist/esm/components/RangeDateField/index.js.map +1 -1
  267. package/dist/esm/components/RangeDatePicker/RangeDatePicker.d.ts +2 -1
  268. package/dist/esm/components/RangeDatePicker/RangeDatePicker.js +4 -6
  269. package/dist/esm/components/RangeDatePicker/RangeDatePicker.js.map +1 -1
  270. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.d.ts +1 -1
  271. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.js +2 -3
  272. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.js.map +1 -1
  273. package/dist/esm/components/RangeDateSelection/RangeDateSelection.d.ts +1 -1
  274. package/dist/esm/components/RangeDateSelection/RangeDateSelection.js +4 -5
  275. package/dist/esm/components/RangeDateSelection/RangeDateSelection.js.map +1 -1
  276. package/dist/esm/components/RangeDateSelection/components/NowLine/NowLine.d.ts +2 -1
  277. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.d.ts +1 -1
  278. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.js +1 -1
  279. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.js.map +1 -1
  280. package/dist/esm/components/RangeDateSelection/components/RulerViewport/RulerViewport.js +2 -2
  281. package/dist/esm/components/RangeDateSelection/components/RulerViewport/RulerViewport.js.map +1 -1
  282. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.d.ts +2 -1
  283. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.js +12 -22
  284. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.js.map +1 -1
  285. package/dist/esm/components/RangeDateSelection/components/Ticks/MiddleTicks.d.ts +1 -1
  286. package/dist/esm/components/RangeDateSelection/components/Ticks/SlitTicks.d.ts +1 -1
  287. package/dist/esm/components/RangeDateSelection/components/Ticks/Ticks.d.ts +2 -2
  288. package/dist/esm/components/RangeDateSelection/components/Ticks/Ticks.js.map +1 -1
  289. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.d.ts +3 -4
  290. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.js +1 -2
  291. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.js.map +1 -1
  292. package/dist/esm/components/RangeDateSelection/hooks/useRangeDateSelectionState.js +9 -10
  293. package/dist/esm/components/RangeDateSelection/hooks/useRangeDateSelectionState.js.map +1 -1
  294. package/dist/esm/components/RangeDateSelection/utils/span.d.ts +2 -1
  295. package/dist/esm/components/RangeDateSelection/utils/span.js.map +1 -1
  296. package/dist/esm/components/RelativeDateField/RelativeDateField.d.ts +1 -1
  297. package/dist/esm/components/RelativeDateField/RelativeDateField.js +4 -40
  298. package/dist/esm/components/RelativeDateField/RelativeDateField.js.map +1 -1
  299. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.d.ts +7 -2
  300. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.js +71 -9
  301. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.js.map +1 -1
  302. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.d.ts +2 -0
  303. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.js +48 -34
  304. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.js.map +1 -1
  305. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.d.ts +1 -1
  306. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.js +7 -4
  307. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.js.map +1 -1
  308. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.d.ts +1 -1
  309. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js +52 -22
  310. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js.map +1 -1
  311. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js +9 -10
  312. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js.map +1 -1
  313. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.d.ts +2 -1
  314. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js +13 -5
  315. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js.map +1 -1
  316. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.css +1 -1
  317. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.css.map +1 -1
  318. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.d.ts +2 -1
  319. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.js +12 -6
  320. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.js.map +1 -1
  321. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.d.ts +1 -1
  322. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js +6 -8
  323. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js.map +1 -1
  324. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.d.ts +5 -3
  325. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js +18 -17
  326. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js.map +1 -1
  327. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.d.ts +2 -1
  328. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js +32 -7
  329. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js.map +1 -1
  330. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.d.ts +3 -3
  331. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js +19 -18
  332. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js.map +1 -1
  333. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.d.ts +6 -9
  334. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.js +8 -10
  335. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.js.map +1 -1
  336. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/defaultPresets.d.ts +2 -2
  337. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/defaultPresets.js.map +1 -1
  338. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.d.ts +9 -4
  339. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.js +26 -15
  340. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.js.map +1 -1
  341. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.d.ts +3 -3
  342. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.js +3 -4
  343. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.js.map +1 -1
  344. package/dist/esm/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js +8 -7
  345. package/dist/esm/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js.map +1 -1
  346. package/dist/esm/components/RelativeRangeDatePicker/utils.d.ts +2 -2
  347. package/dist/esm/components/RelativeRangeDatePicker/utils.js +33 -9
  348. package/dist/esm/components/RelativeRangeDatePicker/utils.js.map +1 -1
  349. package/dist/esm/components/utils/constants.d.ts +2 -0
  350. package/dist/esm/components/utils/constants.js +6 -0
  351. package/dist/esm/components/utils/constants.js.map +1 -1
  352. package/dist/esm/components/utils/dates.d.ts +6 -1
  353. package/dist/esm/components/utils/dates.js +5 -1
  354. package/dist/esm/components/utils/dates.js.map +1 -1
  355. package/dist/esm/components/utils/filterDOMProps.js +1 -1
  356. package/dist/esm/components/utils/filterDOMProps.js.map +1 -1
  357. package/dist/esm/components/utils/mergeProps.js +1 -1
  358. package/dist/esm/components/utils/mergeProps.js.map +1 -1
  359. package/dist/esm/components/utils/validation/datePicker.js +1 -1
  360. package/dist/esm/components/utils/validation/datePicker.js.map +1 -1
  361. package/dist/esm/components/utils/validation/i18n/ru.json +2 -2
  362. package/dist/esm/components/utils/validation/relativeRangeDatePicker.d.ts +7 -11
  363. package/dist/esm/components/utils/validation/relativeRangeDatePicker.js +6 -1
  364. package/dist/esm/components/utils/validation/relativeRangeDatePicker.js.map +1 -1
  365. package/dist/esm/hooks/useEventHandler.js +1 -2
  366. package/dist/esm/hooks/useEventHandler.js.map +1 -1
  367. package/dist/esm/hooks/useMove.d.ts +2 -2
  368. package/dist/esm/hooks/useMove.js +6 -9
  369. package/dist/esm/hooks/useMove.js.map +1 -1
  370. package/dist/esm/hooks/useResizeObserver.js +1 -1
  371. package/dist/esm/hooks/useResizeObserver.js.map +1 -1
  372. package/dist/esm/package.json +1 -1
  373. package/package.json +34 -27
  374. package/dist/cjs/components/RangeDateField/hooks/useRangeDateFieldState.js +0 -224
  375. package/dist/cjs/components/RangeDateField/hooks/useRangeDateFieldState.js.map +0 -1
  376. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.d.ts +0 -5
  377. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.js +0 -9
  378. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.js.map +0 -1
  379. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.d.ts +0 -5
  380. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.js +0 -42
  381. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.js.map +0 -1
  382. package/dist/cjs/components/RangeDateField/utils/index.d.ts +0 -3
  383. package/dist/cjs/components/RangeDateField/utils/index.js +0 -7
  384. package/dist/cjs/components/RangeDateField/utils/index.js.map +0 -1
  385. package/dist/cjs/components/RangeDateField/utils/isValidRange.d.ts +0 -3
  386. package/dist/cjs/components/RangeDateField/utils/isValidRange.js +0 -7
  387. package/dist/cjs/components/RangeDateField/utils/isValidRange.js.map +0 -1
  388. package/dist/esm/components/RangeDateField/hooks/useRangeDateFieldState.js +0 -220
  389. package/dist/esm/components/RangeDateField/hooks/useRangeDateFieldState.js.map +0 -1
  390. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.d.ts +0 -5
  391. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.js +0 -6
  392. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.js.map +0 -1
  393. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.d.ts +0 -5
  394. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.js +0 -39
  395. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.js.map +0 -1
  396. package/dist/esm/components/RangeDateField/utils/index.d.ts +0 -3
  397. package/dist/esm/components/RangeDateField/utils/index.js +0 -4
  398. package/dist/esm/components/RangeDateField/utils/index.js.map +0 -1
  399. package/dist/esm/components/RangeDateField/utils/isValidRange.d.ts +0 -3
  400. package/dist/esm/components/RangeDateField/utils/isValidRange.js +0 -4
  401. package/dist/esm/components/RangeDateField/utils/isValidRange.js.map +0 -1
@@ -1,122 +1,56 @@
1
1
  import React from 'react';
2
- import { createPlaceholderValue } from "../../utils/dates.js";
3
- import { EDITABLE_SEGMENTS, formatSections, getCurrentEditableSectionIndex, getDurationUnitFromSectionType, } from "../utils.js";
4
- const PAGE_STEP = {
5
- year: 5,
6
- quarter: 2,
7
- month: 2,
8
- weekday: 3,
9
- day: 7,
10
- hour: 2,
11
- minute: 15,
12
- second: 15,
13
- };
2
+ import { PAGE_STEP } from "../utils.js";
14
3
  export function useBaseDateFieldState(props) {
15
- const { value, validationState, displayValue, editableSections, formatInfo, selectedSectionIndexes, selectedSections, isEmpty, flushAllValidSections, flushValidSection, setSelectedSections, setValue, setDate, adjustSection, setSection, getSectionValue, setSectionValue, createPlaceholder, setValueFromString, } = props;
16
- const enteredKeys = React.useRef('');
4
+ const { value, validationState, displayValue, editableSections, formatInfo, isEmpty, setValue, adjustSection, setSection, clearSection, setValueFromString, confirmPlaceholder, } = props;
5
+ const [isActive, setActive] = React.useState(false);
17
6
  return {
18
7
  value,
19
8
  isEmpty,
20
9
  displayValue,
21
10
  setValue,
22
- setDate,
23
- text: formatSections(editableSections),
11
+ confirmPlaceholder,
24
12
  readOnly: props.readOnly,
25
13
  disabled: props.disabled,
26
14
  sections: editableSections,
27
15
  formatInfo,
28
- hasDate: formatInfo.hasDate,
29
- hasTime: formatInfo.hasTime,
30
- selectedSectionIndexes,
31
16
  validationState,
32
- setSelectedSections(position) {
33
- enteredKeys.current = '';
34
- setSelectedSections(position);
35
- },
36
- focusSectionInPosition(position) {
37
- const nextSectionIndex = this.sections.findIndex((s) => s.end >= position);
38
- const index = nextSectionIndex === -1 ? 0 : nextSectionIndex;
39
- const nextSection = this.sections[index];
40
- if (nextSection) {
41
- this.setSelectedSections(EDITABLE_SEGMENTS[nextSection.type] ? index : nextSection.nextEditableSection);
42
- }
43
- },
44
- focusNextSection() {
45
- var _a, _b;
46
- const currentIndex = selectedSections === 'all' ? 0 : selectedSections;
47
- const newIndex = (_b = (_a = this.sections[currentIndex]) === null || _a === void 0 ? void 0 : _a.nextEditableSection) !== null && _b !== void 0 ? _b : -1;
48
- if (newIndex !== -1) {
49
- this.setSelectedSections(newIndex);
50
- }
51
- },
52
- focusPreviousSection() {
53
- var _a, _b;
54
- const currentIndex = selectedSections === 'all' ? 0 : selectedSections;
55
- const newIndex = (_b = (_a = this.sections[currentIndex]) === null || _a === void 0 ? void 0 : _a.previousEditableSection) !== null && _b !== void 0 ? _b : -1;
56
- if (newIndex !== -1) {
57
- this.setSelectedSections(newIndex);
58
- }
59
- },
60
- focusFirstSection() {
61
- var _a, _b;
62
- const newIndex = (_b = (_a = this.sections[0]) === null || _a === void 0 ? void 0 : _a.previousEditableSection) !== null && _b !== void 0 ? _b : -1;
63
- if (newIndex !== -1) {
64
- setSelectedSections(newIndex);
65
- }
66
- },
67
- focusLastSection() {
68
- var _a, _b;
69
- const newIndex = (_b = (_a = this.sections[this.sections.length - 1]) === null || _a === void 0 ? void 0 : _a.nextEditableSection) !== null && _b !== void 0 ? _b : -1;
70
- if (newIndex !== -1) {
71
- this.setSelectedSections(newIndex);
72
- }
73
- },
74
- increment() {
17
+ setSection,
18
+ increment(sectionIndex) {
75
19
  if (this.readOnly || this.disabled) {
76
20
  return;
77
21
  }
78
- enteredKeys.current = '';
79
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
80
22
  if (sectionIndex !== -1) {
81
23
  adjustSection(sectionIndex, 1);
82
24
  }
83
25
  },
84
- decrement() {
26
+ decrement(sectionIndex) {
85
27
  if (this.readOnly || this.disabled) {
86
28
  return;
87
29
  }
88
- enteredKeys.current = '';
89
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
90
30
  if (sectionIndex !== -1) {
91
31
  adjustSection(sectionIndex, -1);
92
32
  }
93
33
  },
94
- incrementPage() {
34
+ incrementPage(sectionIndex) {
95
35
  if (this.readOnly || this.disabled) {
96
36
  return;
97
37
  }
98
- enteredKeys.current = '';
99
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
100
38
  if (sectionIndex !== -1) {
101
39
  adjustSection(sectionIndex, PAGE_STEP[this.sections[sectionIndex].type] || 1);
102
40
  }
103
41
  },
104
- decrementPage() {
42
+ decrementPage(sectionIndex) {
105
43
  if (this.readOnly || this.disabled) {
106
44
  return;
107
45
  }
108
- enteredKeys.current = '';
109
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
110
46
  if (sectionIndex !== -1) {
111
47
  adjustSection(sectionIndex, -(PAGE_STEP[this.sections[sectionIndex].type] || 1));
112
48
  }
113
49
  },
114
- incrementToMax() {
50
+ incrementToMax(sectionIndex) {
115
51
  if (this.readOnly || this.disabled) {
116
52
  return;
117
53
  }
118
- enteredKeys.current = '';
119
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
120
54
  if (sectionIndex !== -1) {
121
55
  const section = this.sections[sectionIndex];
122
56
  if (typeof section.maxValue === 'number') {
@@ -124,12 +58,10 @@ export function useBaseDateFieldState(props) {
124
58
  }
125
59
  }
126
60
  },
127
- decrementToMin() {
61
+ decrementToMin(sectionIndex) {
128
62
  if (this.readOnly || this.disabled) {
129
63
  return;
130
64
  }
131
- enteredKeys.current = '';
132
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
133
65
  if (sectionIndex !== -1) {
134
66
  const section = this.sections[sectionIndex];
135
67
  if (typeof section.minValue === 'number') {
@@ -137,187 +69,24 @@ export function useBaseDateFieldState(props) {
137
69
  }
138
70
  }
139
71
  },
140
- clearSection() {
72
+ clearSection(sectionIndex) {
141
73
  if (this.readOnly || this.disabled) {
142
74
  return;
143
75
  }
144
- enteredKeys.current = '';
145
- if (selectedSections === 'all') {
146
- this.clearAll();
147
- return;
148
- }
149
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
150
76
  if (sectionIndex === -1) {
151
77
  return;
152
78
  }
153
- flushValidSection(sectionIndex);
154
- const section = this.sections[sectionIndex];
155
- const placeholder = createPlaceholderValue({
156
- placeholderValue: props.placeholderValue,
157
- timeZone: props.timeZone,
158
- }).timeZone(props.timeZone);
159
- const displayPortion = getSectionValue(sectionIndex);
160
- let currentValue = displayPortion;
161
- // Reset day period to default without changing the hour.
162
- if (section.type === 'dayPeriod') {
163
- const isPM = displayPortion.hour() >= 12;
164
- const shouldBePM = placeholder.hour() >= 12;
165
- if (isPM && !shouldBePM) {
166
- currentValue = displayPortion.set('hour', displayPortion.hour() - 12);
167
- }
168
- else if (!isPM && shouldBePM) {
169
- currentValue = displayPortion.set('hour', displayPortion.hour() + 12);
170
- }
171
- }
172
- else {
173
- const type = getDurationUnitFromSectionType(section.type);
174
- currentValue = displayPortion.set(type, placeholder[type]());
175
- }
176
- setSectionValue(sectionIndex, currentValue);
79
+ clearSection(sectionIndex);
177
80
  },
178
81
  clearAll() {
179
82
  if (this.readOnly || this.disabled) {
180
83
  return;
181
84
  }
182
- enteredKeys.current = '';
183
- flushAllValidSections();
184
- if (value !== null) {
185
- setDate(null);
186
- }
187
- const date = createPlaceholder();
188
- setValue(date);
189
- },
190
- onInput(key) {
191
- if (this.readOnly || this.disabled) {
192
- return;
193
- }
194
- const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);
195
- if (sectionIndex === -1) {
196
- return;
197
- }
198
- const section = this.sections[sectionIndex];
199
- const isLastSection = section.nextEditableSection === sectionIndex;
200
- let newValue = enteredKeys.current + key;
201
- const onInputNumber = (numberValue) => {
202
- var _a;
203
- let sectionValue = section.type === 'month' ? numberValue - 1 : numberValue;
204
- const sectionMaxValue = (_a = section.maxValue) !== null && _a !== void 0 ? _a : 0;
205
- const allowsZero = section.minValue === 0;
206
- let shouldResetUserInput;
207
- if (
208
- // 12-hour clock format with AM/PM
209
- section.type === 'hour' &&
210
- (sectionMaxValue === 11 || section.minValue === 12)) {
211
- if (sectionValue > 12) {
212
- sectionValue = Number(key);
213
- newValue = key;
214
- }
215
- if (sectionValue === 0) {
216
- sectionValue = -Infinity;
217
- }
218
- if (sectionValue === 12) {
219
- sectionValue = 0;
220
- }
221
- if (section.minValue === 12) {
222
- sectionValue += 12;
223
- }
224
- shouldResetUserInput = Number(newValue + '0') > 12;
225
- }
226
- else if (sectionValue > sectionMaxValue) {
227
- sectionValue = Number(key) - (section.type === 'month' ? 1 : 0);
228
- newValue = key;
229
- if (sectionValue > sectionMaxValue) {
230
- enteredKeys.current = '';
231
- return;
232
- }
233
- }
234
- const shouldSetValue = sectionValue > 0 || (sectionValue === 0 && allowsZero);
235
- if (shouldSetValue) {
236
- setSection(sectionIndex, sectionValue);
237
- }
238
- if (shouldResetUserInput === undefined) {
239
- shouldResetUserInput = Number(newValue + '0') > sectionMaxValue;
240
- }
241
- const isMaxLength = newValue.length >= String(sectionMaxValue).length;
242
- if (shouldResetUserInput) {
243
- enteredKeys.current = '';
244
- if (shouldSetValue) {
245
- this.focusNextSection();
246
- }
247
- }
248
- else if (isMaxLength && shouldSetValue && !isLastSection) {
249
- this.focusNextSection();
250
- }
251
- else {
252
- enteredKeys.current = newValue;
253
- }
254
- };
255
- const onInputString = (stringValue) => {
256
- var _a;
257
- const options = (_a = section.options) !== null && _a !== void 0 ? _a : [];
258
- let sectionValue = stringValue.toLocaleUpperCase();
259
- let foundOptions = options.filter((v) => v.startsWith(sectionValue));
260
- if (foundOptions.length === 0) {
261
- if (stringValue !== key) {
262
- sectionValue = key.toLocaleUpperCase();
263
- foundOptions = options.filter((v) => v.startsWith(sectionValue));
264
- }
265
- if (foundOptions.length === 0) {
266
- enteredKeys.current = '';
267
- return;
268
- }
269
- }
270
- const foundValue = foundOptions[0];
271
- const index = options.indexOf(foundValue);
272
- if (section.type === 'dayPeriod') {
273
- setSection(sectionIndex, index === 1 ? 12 : 0);
274
- }
275
- else {
276
- setSection(sectionIndex, index);
277
- }
278
- if (foundOptions.length > 1) {
279
- enteredKeys.current = newValue;
280
- }
281
- else {
282
- enteredKeys.current = '';
283
- this.focusNextSection();
284
- }
285
- };
286
- switch (section.type) {
287
- case 'day':
288
- case 'hour':
289
- case 'minute':
290
- case 'second':
291
- case 'quarter':
292
- case 'year': {
293
- if (!Number.isInteger(Number(newValue))) {
294
- return;
295
- }
296
- const numberValue = Number(newValue);
297
- onInputNumber(numberValue);
298
- break;
299
- }
300
- case 'dayPeriod': {
301
- onInputString(newValue);
302
- break;
303
- }
304
- case 'weekday':
305
- case 'month': {
306
- if (Number.isInteger(Number(newValue))) {
307
- const numberValue = Number(newValue);
308
- onInputNumber(numberValue);
309
- }
310
- else {
311
- onInputString(newValue);
312
- }
313
- break;
314
- }
315
- }
316
- },
317
- setValueFromString(str) {
318
- enteredKeys.current = '';
319
- return setValueFromString(str);
85
+ setValue(null);
320
86
  },
87
+ setValueFromString,
88
+ isActive,
89
+ setActive,
321
90
  };
322
91
  }
323
92
  //# sourceMappingURL=useBaseDateFieldState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBaseDateFieldState.js","sourceRoot":"../../../../../src","sources":["components/DateField/hooks/useBaseDateFieldState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAC,sBAAsB,EAAC,6BAA0B;AAEzD,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,8BAA8B,EAC9B,8BAA8B,GACjC,oBAAiB;AAElB,MAAM,SAAS,GAAkD;IAC7D,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACb,CAAC;AAuGF,MAAM,UAAU,qBAAqB,CACjC,KAAmC;IAEnC,MAAM,EACF,KAAK,EACL,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,sBAAsB,EACtB,gBAAgB,EAChB,OAAO,EACP,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,aAAa,EACb,UAAU,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACrB,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAErC,OAAO;QACH,KAAK;QACL,OAAO;QACP,YAAY;QACZ,QAAQ;QACR,OAAO;QACP,IAAI,EAAE,cAAc,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,UAAU;QACV,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,sBAAsB;QACtB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CAAC,QAAQ,CAAC,CAAC;wBACrC,aAAa,CAAC,WAAW,CAAC,CAAC;oBAC/B,CAAC;yBAAM,CAAC;wBACJ,aAAa,CAAC,QAAQ,CAAC,CAAC;oBAC5B,CAAC;oBACD,MAAM;gBACV,CAAC;YACL,CAAC;QACL,CAAC;QACD,kBAAkB,CAAC,GAAW;YAC1B,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;YACzB,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\n\nimport type {ValidationState} from '../../types';\nimport {createPlaceholderValue} from '../../utils/dates';\nimport type {DateFieldSection, DateFieldSectionType, FormatInfo} from '../types';\nimport {\n EDITABLE_SEGMENTS,\n formatSections,\n getCurrentEditableSectionIndex,\n getDurationUnitFromSectionType,\n} from '../utils';\n\nconst PAGE_STEP: Partial<Record<DateFieldSectionType, number>> = {\n year: 5,\n quarter: 2,\n month: 2,\n weekday: 3,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15,\n};\n\nexport type BaseDateFieldStateOptions<T = DateTime> = {\n value: T | null;\n displayValue: T;\n placeholderValue?: DateTime;\n timeZone: string;\n validationState?: ValidationState;\n editableSections: DateFieldSection[];\n formatInfo: FormatInfo;\n readOnly?: boolean;\n disabled?: boolean;\n selectedSectionIndexes: {startIndex: number; endIndex: number} | null;\n selectedSections: number | 'all';\n isEmpty: boolean;\n flushAllValidSections: () => void;\n flushValidSection: (sectionIndex: number) => void;\n setSelectedSections: (position: number | 'all') => void;\n setValue: (value: T) => void;\n setDate: (value: T | null) => void;\n adjustSection: (sectionIndex: number, amount: number) => void;\n setSection: (sectionIndex: number, amount: number) => void;\n getSectionValue: (sectionIndex: number) => DateTime;\n setSectionValue: (sectionIndex: number, currentValue: DateTime) => void;\n createPlaceholder: () => T;\n setValueFromString: (str: string) => boolean;\n};\n\nexport type DateFieldState<T = DateTime> = {\n /** The current field value. */\n value: T | null;\n /** Is no part of value is filled. */\n isEmpty: boolean;\n /** The current used value. value or placeholderValue */\n displayValue: T;\n /** Sets the field's value. */\n setValue: (value: T) => void;\n /** Sets the date value. */\n setDate: (value: T | null) => void;\n /** Formatted value */\n text: string;\n /** Whether the field is read only. */\n readOnly?: boolean;\n /** Whether the field is disabled. */\n disabled?: boolean;\n /** A list of segments for the current value. */\n sections: DateFieldSection[];\n /** Some info about available sections */\n formatInfo: FormatInfo;\n /**\n * @deprecated use formatInfo.hasDate instead.\n * Whether the the format is containing date parts\n */\n hasDate: boolean;\n /**\n * @deprecated use formatInfo.hasTime instead.\n * Whether the the format is containing time parts\n */\n hasTime: boolean;\n /** Selected sections */\n selectedSectionIndexes: {startIndex: number; endIndex: number} | null;\n /** The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props. */\n validationState?: ValidationState;\n /** Sets selection for segment in position. */\n setSelectedSections: (position: number | 'all') => void;\n /** Focuses segment in position */\n focusSectionInPosition: (position: number) => void;\n /** Focuses the next segment if present */\n focusNextSection: () => void;\n /** Focuses the previous segment if present */\n focusPreviousSection: () => void;\n /** Focuses the first segment */\n focusFirstSection: () => void;\n /** Focuses the last segment */\n focusLastSection: () => void;\n /** Increments the currently selected segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment: () => void;\n /** Decrements the currently selected segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement: () => void;\n /**\n * Increments the currently selected segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage: () => void;\n /**\n * Decrements the currently selected segment by a larger amount, rounding it to the nearest decrement.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage: () => void;\n incrementToMax: () => void;\n decrementToMin: () => void;\n /** Clears the value of the currently selected segment, reverting it to the placeholder. */\n clearSection: () => void;\n /** Clears all segments, reverting them to the placeholder. */\n clearAll: () => void;\n /** Handles input key in the currently selected segment */\n onInput: (key: string) => void;\n //** Tries to set value from str. Supports date in input format or ISO */\n setValueFromString: (str: string) => boolean;\n};\n\nexport function useBaseDateFieldState<T = DateTime>(\n props: BaseDateFieldStateOptions<T>,\n): DateFieldState<T> {\n const {\n value,\n validationState,\n displayValue,\n editableSections,\n formatInfo,\n selectedSectionIndexes,\n selectedSections,\n isEmpty,\n flushAllValidSections,\n flushValidSection,\n setSelectedSections,\n setValue,\n setDate,\n adjustSection,\n setSection,\n getSectionValue,\n setSectionValue,\n createPlaceholder,\n setValueFromString,\n } = props;\n\n const enteredKeys = React.useRef('');\n\n return {\n value,\n isEmpty,\n displayValue,\n setValue,\n setDate,\n text: formatSections(editableSections),\n readOnly: props.readOnly,\n disabled: props.disabled,\n sections: editableSections,\n formatInfo,\n hasDate: formatInfo.hasDate,\n hasTime: formatInfo.hasTime,\n selectedSectionIndexes,\n validationState,\n setSelectedSections(position) {\n enteredKeys.current = '';\n setSelectedSections(position);\n },\n focusSectionInPosition(position) {\n const nextSectionIndex = this.sections.findIndex((s) => s.end >= position);\n const index = nextSectionIndex === -1 ? 0 : nextSectionIndex;\n const nextSection = this.sections[index];\n if (nextSection) {\n this.setSelectedSections(\n EDITABLE_SEGMENTS[nextSection.type] ? index : nextSection.nextEditableSection,\n );\n }\n },\n focusNextSection() {\n const currentIndex = selectedSections === 'all' ? 0 : selectedSections;\n const newIndex = this.sections[currentIndex]?.nextEditableSection ?? -1;\n if (newIndex !== -1) {\n this.setSelectedSections(newIndex);\n }\n },\n focusPreviousSection() {\n const currentIndex = selectedSections === 'all' ? 0 : selectedSections;\n const newIndex = this.sections[currentIndex]?.previousEditableSection ?? -1;\n if (newIndex !== -1) {\n this.setSelectedSections(newIndex);\n }\n },\n focusFirstSection() {\n const newIndex = this.sections[0]?.previousEditableSection ?? -1;\n if (newIndex !== -1) {\n setSelectedSections(newIndex);\n }\n },\n focusLastSection() {\n const newIndex = this.sections[this.sections.length - 1]?.nextEditableSection ?? -1;\n if (newIndex !== -1) {\n this.setSelectedSections(newIndex);\n }\n },\n increment() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, 1);\n }\n },\n decrement() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, -1);\n }\n },\n incrementPage() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, PAGE_STEP[this.sections[sectionIndex].type] || 1);\n }\n },\n decrementPage() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, -(PAGE_STEP[this.sections[sectionIndex].type] || 1));\n }\n },\n incrementToMax() {\n if (this.readOnly || this.disabled) {\n return;\n }\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n const section = this.sections[sectionIndex];\n if (typeof section.maxValue === 'number') {\n setSection(sectionIndex, section.maxValue);\n }\n }\n },\n decrementToMin() {\n if (this.readOnly || this.disabled) {\n return;\n }\n enteredKeys.current = '';\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex !== -1) {\n const section = this.sections[sectionIndex];\n if (typeof section.minValue === 'number') {\n setSection(sectionIndex, section.minValue);\n }\n }\n },\n clearSection() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n if (selectedSections === 'all') {\n this.clearAll();\n return;\n }\n\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex === -1) {\n return;\n }\n\n flushValidSection(sectionIndex);\n\n const section = this.sections[sectionIndex];\n\n const placeholder = createPlaceholderValue({\n placeholderValue: props.placeholderValue,\n timeZone: props.timeZone,\n }).timeZone(props.timeZone);\n\n const displayPortion = getSectionValue(sectionIndex);\n let currentValue = displayPortion;\n\n // Reset day period to default without changing the hour.\n if (section.type === 'dayPeriod') {\n const isPM = displayPortion.hour() >= 12;\n const shouldBePM = placeholder.hour() >= 12;\n if (isPM && !shouldBePM) {\n currentValue = displayPortion.set('hour', displayPortion.hour() - 12);\n } else if (!isPM && shouldBePM) {\n currentValue = displayPortion.set('hour', displayPortion.hour() + 12);\n }\n } else {\n const type = getDurationUnitFromSectionType(section.type);\n currentValue = displayPortion.set(type, placeholder[type]());\n }\n\n setSectionValue(sectionIndex, currentValue);\n },\n clearAll() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n enteredKeys.current = '';\n flushAllValidSections();\n if (value !== null) {\n setDate(null);\n }\n\n const date = createPlaceholder();\n\n setValue(date);\n },\n onInput(key: string) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n const sectionIndex = getCurrentEditableSectionIndex(this.sections, selectedSections);\n if (sectionIndex === -1) {\n return;\n }\n\n const section = this.sections[sectionIndex];\n const isLastSection = section.nextEditableSection === sectionIndex;\n let newValue = enteredKeys.current + key;\n\n const onInputNumber = (numberValue: number) => {\n let sectionValue = section.type === 'month' ? numberValue - 1 : numberValue;\n const sectionMaxValue = section.maxValue ?? 0;\n const allowsZero = section.minValue === 0;\n let shouldResetUserInput;\n if (\n // 12-hour clock format with AM/PM\n section.type === 'hour' &&\n (sectionMaxValue === 11 || section.minValue === 12)\n ) {\n if (sectionValue > 12) {\n sectionValue = Number(key);\n newValue = key;\n }\n if (sectionValue === 0) {\n sectionValue = -Infinity;\n }\n if (sectionValue === 12) {\n sectionValue = 0;\n }\n if (section.minValue === 12) {\n sectionValue += 12;\n }\n shouldResetUserInput = Number(newValue + '0') > 12;\n } else if (sectionValue > sectionMaxValue) {\n sectionValue = Number(key) - (section.type === 'month' ? 1 : 0);\n newValue = key;\n if (sectionValue > sectionMaxValue) {\n enteredKeys.current = '';\n return;\n }\n }\n\n const shouldSetValue = sectionValue > 0 || (sectionValue === 0 && allowsZero);\n if (shouldSetValue) {\n setSection(sectionIndex, sectionValue);\n }\n\n if (shouldResetUserInput === undefined) {\n shouldResetUserInput = Number(newValue + '0') > sectionMaxValue;\n }\n const isMaxLength = newValue.length >= String(sectionMaxValue).length;\n if (shouldResetUserInput) {\n enteredKeys.current = '';\n if (shouldSetValue) {\n this.focusNextSection();\n }\n } else if (isMaxLength && shouldSetValue && !isLastSection) {\n this.focusNextSection();\n } else {\n enteredKeys.current = newValue;\n }\n };\n\n const onInputString = (stringValue: string) => {\n const options = section.options ?? [];\n let sectionValue = stringValue.toLocaleUpperCase();\n let foundOptions = options.filter((v) => v.startsWith(sectionValue));\n if (foundOptions.length === 0) {\n if (stringValue !== key) {\n sectionValue = key.toLocaleUpperCase();\n foundOptions = options.filter((v) => v.startsWith(sectionValue));\n }\n if (foundOptions.length === 0) {\n enteredKeys.current = '';\n return;\n }\n }\n const foundValue = foundOptions[0];\n const index = options.indexOf(foundValue);\n\n if (section.type === 'dayPeriod') {\n setSection(sectionIndex, index === 1 ? 12 : 0);\n } else {\n setSection(sectionIndex, index);\n }\n\n if (foundOptions.length > 1) {\n enteredKeys.current = newValue;\n } else {\n enteredKeys.current = '';\n this.focusNextSection();\n }\n };\n\n switch (section.type) {\n case 'day':\n case 'hour':\n case 'minute':\n case 'second':\n case 'quarter':\n case 'year': {\n if (!Number.isInteger(Number(newValue))) {\n return;\n }\n const numberValue = Number(newValue);\n onInputNumber(numberValue);\n break;\n }\n case 'dayPeriod': {\n onInputString(newValue);\n break;\n }\n case 'weekday':\n case 'month': {\n if (Number.isInteger(Number(newValue))) {\n const numberValue = Number(newValue);\n onInputNumber(numberValue);\n } else {\n onInputString(newValue);\n }\n break;\n }\n }\n },\n setValueFromString(str: string) {\n enteredKeys.current = '';\n return setValueFromString(str);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"useBaseDateFieldState.js","sourceRoot":"../../../../../src","sources":["components/DateField/hooks/useBaseDateFieldState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAC,SAAS,EAAC,oBAAiB;AAwEnC,MAAM,UAAU,qBAAqB,CACjC,KAAsC;IAEtC,MAAM,EACF,KAAK,EACL,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACrB,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,OAAO;QACH,KAAK;QACL,OAAO;QACP,YAAY;QACZ,QAAQ;QACR,kBAAkB;QAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,UAAU;QACV,eAAe;QACf,UAAU;QACV,SAAS,CAAC,YAAY;YAClB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjC,OAAO;YACX,CAAC;YAED,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;gBACtB,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;QACD,SAAS,CAAC,YAAY;YAClB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjC,OAAO;YACX,CAAC;YAED,IAAI,YAAY,KAAK,CAA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YACX,CAAC;YACD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;gBACtB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBAC5C,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;oBACvC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC/C,CAAC;YACL,CAAC;QACL,CAAC;QACD,YAAY,CAAC,YAAY;YACrB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjC,OAAO;YACX,CAAC;YAED,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;gBACtB,OAAO;YACX,CAAC;YAED,YAAY,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;QACD,QAAQ;YACJ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjC,OAAO;YACX,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QACD,kBAAkB;QAClB,QAAQ;QACR,SAAS;KACZ,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\n\nimport type {ValidationState} from '../../types';\nimport type {IncompleteDate} from '../IncompleteDate';\nimport type {DateFieldSection, FormatInfo} from '../types';\nimport {PAGE_STEP} from '../utils';\n\ninterface BaseDateFieldStateOptions<T = DateTime, V = IncompleteDate> {\n value: T | null;\n displayValue: T;\n validationState?: ValidationState;\n editableSections: DateFieldSection[];\n formatInfo: FormatInfo;\n readOnly?: boolean;\n disabled?: boolean;\n isEmpty: boolean;\n setValue: (value: T | V | null) => void;\n adjustSection: (sectionIndex: number, amount: number) => void;\n setSection: (sectionIndex: number, amount: number) => void;\n clearSection: (sectionIndex: number) => void;\n setValueFromString: (str: string) => boolean;\n confirmPlaceholder: () => void;\n}\n\nexport interface DateFieldState<T = DateTime> {\n /** The current field value. */\n value: T | null;\n /** Is no part of value is filled. */\n isEmpty: boolean;\n /** The current used value. value or placeholderValue */\n displayValue: T;\n /** Sets the field's value. */\n setValue: (value: T | null) => void;\n /** Updates the remaining unfilled sections with the placeholder value. */\n confirmPlaceholder: () => void;\n /** Whether the field is read only. */\n readOnly?: boolean;\n /** Whether the field is disabled. */\n disabled?: boolean;\n /** A list of sections for the current value. */\n sections: DateFieldSection[];\n /** Some info about available sections */\n formatInfo: FormatInfo;\n /** The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props. */\n validationState?: ValidationState;\n /** Increments the currently selected section. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment: (sectionIndex: number) => void;\n /** Decrements the currently selected section. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement: (sectionIndex: number) => void;\n /**\n * Increments the currently selected section by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage: (sectionIndex: number) => void;\n /**\n * Decrements the currently selected section by a larger amount, rounding it to the nearest decrement.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage: (sectionIndex: number) => void;\n incrementToMax: (sectionIndex: number) => void;\n decrementToMin: (sectionIndex: number) => void;\n /** Clears the value of the currently selected section, reverting it to the placeholder. */\n clearSection: (sectionIndex: number) => void;\n /** Clears all sections, reverting them to the placeholder. */\n clearAll: () => void;\n /** Sets the value of the given section. */\n setSection: (sectionIndex: number, amount: number) => void;\n /** Tries to set value from str. Supports date in input format or ISO */\n setValueFromString: (str: string) => boolean;\n /** Is date filed active now */\n isActive: boolean;\n /** Sets active state of the date field */\n setActive: (isActive: boolean) => void;\n}\n\nexport function useBaseDateFieldState<T = DateTime, V = IncompleteDate>(\n props: BaseDateFieldStateOptions<T, V>,\n): DateFieldState<T> {\n const {\n value,\n validationState,\n displayValue,\n editableSections,\n formatInfo,\n isEmpty,\n setValue,\n adjustSection,\n setSection,\n clearSection,\n setValueFromString,\n confirmPlaceholder,\n } = props;\n\n const [isActive, setActive] = React.useState(false);\n\n return {\n value,\n isEmpty,\n displayValue,\n setValue,\n confirmPlaceholder,\n readOnly: props.readOnly,\n disabled: props.disabled,\n sections: editableSections,\n formatInfo,\n validationState,\n setSection,\n increment(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, 1);\n }\n },\n decrement(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, -1);\n }\n },\n incrementPage(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, PAGE_STEP[this.sections[sectionIndex].type] || 1);\n }\n },\n decrementPage(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n if (sectionIndex !== -1) {\n adjustSection(sectionIndex, -(PAGE_STEP[this.sections[sectionIndex].type] || 1));\n }\n },\n incrementToMax(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n if (sectionIndex !== -1) {\n const section = this.sections[sectionIndex];\n if (typeof section.maxValue === 'number') {\n setSection(sectionIndex, section.maxValue);\n }\n }\n },\n decrementToMin(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n if (sectionIndex !== -1) {\n const section = this.sections[sectionIndex];\n if (typeof section.minValue === 'number') {\n setSection(sectionIndex, section.minValue);\n }\n }\n },\n clearSection(sectionIndex) {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n if (sectionIndex === -1) {\n return;\n }\n\n clearSection(sectionIndex);\n },\n clearAll() {\n if (this.readOnly || this.disabled) {\n return;\n }\n\n setValue(null);\n },\n setValueFromString,\n isActive,\n setActive,\n };\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { DateTime } from '@gravity-ui/date-utils';
2
3
  import type { TextInputProps } from '@gravity-ui/uikit';
3
4
  import type { AccessibilityProps, DateFieldBase, TextInputProps as DateFieldTextInputProps, DomProps, FocusableProps, InputDOMProps, KeyboardEvents, StyleProps, TextInputExtendProps } from "../../types/index.js";
@@ -5,5 +6,6 @@ import type { DateFieldState } from "./useBaseDateFieldState.js";
5
6
  export interface DateFieldProps<T = DateTime> extends DateFieldBase<T>, DateFieldTextInputProps, TextInputExtendProps, DomProps, InputDOMProps, FocusableProps, KeyboardEvents, StyleProps, AccessibilityProps {
6
7
  }
7
8
  export declare function useDateFieldProps<T = DateTime>(state: DateFieldState<T>, props: DateFieldProps<T>): {
9
+ groupProps: React.HTMLAttributes<unknown>;
8
10
  inputProps: TextInputProps;
9
11
  };