@consta/uikit 3.20.0 → 3.21.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 (363) hide show
  1. package/Attach/package.json +1 -1
  2. package/Attachment/package.json +1 -1
  3. package/Avatar/package.json +1 -1
  4. package/Badge/package.json +1 -1
  5. package/BasicSelectDeprecated/package.json +1 -1
  6. package/Breadcrumbs/package.json +1 -1
  7. package/BreadcrumbsCanary/package.json +1 -1
  8. package/Button/package.json +1 -1
  9. package/CHANGELOG.md +14 -22
  10. package/Calendar/package.json +1 -1
  11. package/Card/package.json +1 -1
  12. package/Checkbox/package.json +1 -1
  13. package/CheckboxGroup/package.json +1 -1
  14. package/ChoiceGroup/package.json +1 -1
  15. package/Collapse/package.json +1 -1
  16. package/CollapseGroup/package.json +1 -1
  17. package/Combobox/package.json +1 -1
  18. package/ComboboxDeprecated/package.json +1 -1
  19. package/ContextMenu/package.json +1 -1
  20. package/ContextMenuCanary/package.json +1 -1
  21. package/DatePickerCanary/package.json +1 -1
  22. package/DateTimeCanary/package.json +1 -1
  23. package/DragNDropField/package.json +1 -1
  24. package/EventInterceptor/package.json +1 -1
  25. package/FieldCaption/package.json +1 -1
  26. package/FieldLabel/package.json +1 -1
  27. package/File/package.json +1 -1
  28. package/FileField/package.json +1 -1
  29. package/FileIcon/package.json +1 -1
  30. package/FileIconAvi/package.json +1 -1
  31. package/FileIconBmp/package.json +1 -1
  32. package/FileIconCsv/package.json +1 -1
  33. package/FileIconDoc/package.json +1 -1
  34. package/FileIconExe/package.json +1 -1
  35. package/FileIconGif/package.json +1 -1
  36. package/FileIconJpg/package.json +1 -1
  37. package/FileIconJson/package.json +1 -1
  38. package/FileIconLoading/package.json +1 -1
  39. package/FileIconMov/package.json +1 -1
  40. package/FileIconMp3/package.json +1 -1
  41. package/FileIconMp4/package.json +1 -1
  42. package/FileIconPdf/package.json +1 -1
  43. package/FileIconPng/package.json +1 -1
  44. package/FileIconPtt/package.json +1 -1
  45. package/FileIconRar/package.json +1 -1
  46. package/FileIconRtf/package.json +1 -1
  47. package/FileIconTiff/package.json +1 -1
  48. package/FileIconTxt/package.json +1 -1
  49. package/FileIconUndefined/package.json +1 -1
  50. package/FileIconWav/package.json +1 -1
  51. package/FileIconXls/package.json +1 -1
  52. package/FileIconZip/package.json +1 -1
  53. package/Grid/package.json +1 -1
  54. package/Header/package.json +1 -1
  55. package/Icon/package.json +1 -1
  56. package/IconAdd/package.json +1 -1
  57. package/IconAddToComparison/package.json +1 -1
  58. package/IconAlert/package.json +1 -1
  59. package/IconAlignBlocksLeft/package.json +1 -1
  60. package/IconAlignBlocksRight/package.json +1 -1
  61. package/IconAlignCenter/package.json +1 -1
  62. package/IconAlignJustify/package.json +1 -1
  63. package/IconAlignLeft/package.json +1 -1
  64. package/IconAlignRight/package.json +1 -1
  65. package/IconAllDone/package.json +1 -1
  66. package/IconArrowDown/package.json +1 -1
  67. package/IconArrowLeft/package.json +1 -1
  68. package/IconArrowRight/package.json +1 -1
  69. package/IconArrowUp/package.json +1 -1
  70. package/IconArtBrush/package.json +1 -1
  71. package/IconAttach/package.json +1 -1
  72. package/IconBackward/package.json +1 -1
  73. package/IconBag/package.json +1 -1
  74. package/IconBarrier/package.json +1 -1
  75. package/IconBento/package.json +1 -1
  76. package/IconBold/package.json +1 -1
  77. package/IconBook/package.json +1 -1
  78. package/IconBookmarkFilled/package.json +1 -1
  79. package/IconBookmarkStroked/package.json +1 -1
  80. package/IconCalculator/package.json +1 -1
  81. package/IconCalendar/package.json +1 -1
  82. package/IconCamera/package.json +1 -1
  83. package/IconCancel/package.json +1 -1
  84. package/IconCards/package.json +1 -1
  85. package/IconChat/package.json +1 -1
  86. package/IconCheck/package.json +1 -1
  87. package/IconClose/package.json +1 -1
  88. package/IconCollapse/package.json +1 -1
  89. package/IconColorFill/package.json +1 -1
  90. package/IconColorText/package.json +1 -1
  91. package/IconColumns/package.json +1 -1
  92. package/IconComment/package.json +1 -1
  93. package/IconConnection/package.json +1 -1
  94. package/IconCopy/package.json +1 -1
  95. package/IconCrown/package.json +1 -1
  96. package/IconCursorMouse/package.json +1 -1
  97. package/IconDataNull/package.json +1 -1
  98. package/IconDiamond/package.json +1 -1
  99. package/IconDinosaur/package.json +1 -1
  100. package/IconDisconnection/package.json +1 -1
  101. package/IconDocAdd/package.json +1 -1
  102. package/IconDocBlank/package.json +1 -1
  103. package/IconDocDelete/package.json +1 -1
  104. package/IconDocExport/package.json +1 -1
  105. package/IconDocFilled/package.json +1 -1
  106. package/IconDown/package.json +1 -1
  107. package/IconDownload/package.json +1 -1
  108. package/IconDrag/package.json +1 -1
  109. package/IconDraggable/package.json +1 -1
  110. package/IconDrillingRig/package.json +1 -1
  111. package/IconDrop/package.json +1 -1
  112. package/IconEdit/package.json +1 -1
  113. package/IconExit/package.json +1 -1
  114. package/IconExpand/package.json +1 -1
  115. package/IconEye/package.json +1 -1
  116. package/IconEyeClose/package.json +1 -1
  117. package/IconFacebook/package.json +1 -1
  118. package/IconFavorite/package.json +1 -1
  119. package/IconFilter/package.json +1 -1
  120. package/IconFitToDefault/package.json +1 -1
  121. package/IconFlagFilled/package.json +1 -1
  122. package/IconFlagStroked/package.json +1 -1
  123. package/IconFolders/package.json +1 -1
  124. package/IconForward/package.json +1 -1
  125. package/IconFunnel/package.json +1 -1
  126. package/IconGas/package.json +1 -1
  127. package/IconGeo/package.json +1 -1
  128. package/IconGrouping/package.json +1 -1
  129. package/IconHamburger/package.json +1 -1
  130. package/IconHand/package.json +1 -1
  131. package/IconHealth/package.json +1 -1
  132. package/IconHome/package.json +1 -1
  133. package/IconInComparison/package.json +1 -1
  134. package/IconInfo/package.json +1 -1
  135. package/IconInstagram/package.json +1 -1
  136. package/IconIntroduction/package.json +1 -1
  137. package/IconIpad/package.json +1 -1
  138. package/IconItalic/package.json +1 -1
  139. package/IconKebab/package.json +1 -1
  140. package/IconLaptop/package.json +1 -1
  141. package/IconLayers/package.json +1 -1
  142. package/IconLeaf/package.json +1 -1
  143. package/IconLightningBolt/package.json +1 -1
  144. package/IconLineAndBarChart/package.json +1 -1
  145. package/IconLink/package.json +1 -1
  146. package/IconList/package.json +1 -1
  147. package/IconListNumbered/package.json +1 -1
  148. package/IconLock/package.json +1 -1
  149. package/IconLogicalElement/package.json +1 -1
  150. package/IconMBU/package.json +1 -1
  151. package/IconMGRP/package.json +1 -1
  152. package/IconMLSP/package.json +1 -1
  153. package/IconMMP/package.json +1 -1
  154. package/IconMail/package.json +1 -1
  155. package/IconMap/package.json +1 -1
  156. package/IconMaxHeight/package.json +1 -1
  157. package/IconMaxWidth/package.json +1 -1
  158. package/IconMeatball/package.json +1 -1
  159. package/IconMic/package.json +1 -1
  160. package/IconMolecules/package.json +1 -1
  161. package/IconMoon/package.json +1 -1
  162. package/IconNodeEnd/package.json +1 -1
  163. package/IconNodeStart/package.json +1 -1
  164. package/IconNodeStep/package.json +1 -1
  165. package/IconNodes/package.json +1 -1
  166. package/IconOpenInNew/package.json +1 -1
  167. package/IconOperators/package.json +1 -1
  168. package/IconPanelBottom/package.json +1 -1
  169. package/IconPanelLeft/package.json +1 -1
  170. package/IconPanelRight/package.json +1 -1
  171. package/IconPanelTop/package.json +1 -1
  172. package/IconPaste/package.json +1 -1
  173. package/IconPause/package.json +1 -1
  174. package/IconPhone/package.json +1 -1
  175. package/IconPhoto/package.json +1 -1
  176. package/IconPicture/package.json +1 -1
  177. package/IconPlay/package.json +1 -1
  178. package/IconPressure/package.json +1 -1
  179. package/IconPriceLabel/package.json +1 -1
  180. package/IconProcessing/package.json +1 -1
  181. package/IconQuestion/package.json +1 -1
  182. package/IconQuote/package.json +1 -1
  183. package/IconRUO/package.json +1 -1
  184. package/IconRUS/package.json +1 -1
  185. package/IconRecord/package.json +1 -1
  186. package/IconRemove/package.json +1 -1
  187. package/IconRemoveFromComparison/package.json +1 -1
  188. package/IconReply/package.json +1 -1
  189. package/IconResize/package.json +1 -1
  190. package/IconRestart/package.json +1 -1
  191. package/IconRevert/package.json +1 -1
  192. package/IconRing/package.json +1 -1
  193. package/IconRouble/package.json +1 -1
  194. package/IconRuler/package.json +1 -1
  195. package/IconSave/package.json +1 -1
  196. package/IconScreen/package.json +1 -1
  197. package/IconSearch/package.json +1 -1
  198. package/IconSelect/package.json +1 -1
  199. package/IconSelectOpen/package.json +1 -1
  200. package/IconSendMessage/package.json +1 -1
  201. package/IconSettings/package.json +1 -1
  202. package/IconShape/package.json +1 -1
  203. package/IconShuffle/package.json +1 -1
  204. package/IconSmile/package.json +1 -1
  205. package/IconSortDown/package.json +1 -1
  206. package/IconSortDownCenter/package.json +1 -1
  207. package/IconSortUp/package.json +1 -1
  208. package/IconSortUpCenter/package.json +1 -1
  209. package/IconStop/package.json +1 -1
  210. package/IconStorage/package.json +1 -1
  211. package/IconStrikethrough/package.json +1 -1
  212. package/IconSun/package.json +1 -1
  213. package/IconTable/package.json +1 -1
  214. package/IconTable2/package.json +1 -1
  215. package/IconTarget/package.json +1 -1
  216. package/IconTeam/package.json +1 -1
  217. package/IconTechResponse/package.json +1 -1
  218. package/IconTest/package.json +1 -1
  219. package/IconThumbUp/package.json +1 -1
  220. package/IconTie/package.json +1 -1
  221. package/IconTop/package.json +1 -1
  222. package/IconTrash/package.json +1 -1
  223. package/IconType/package.json +1 -1
  224. package/IconUnderline/package.json +1 -1
  225. package/IconUnlock/package.json +1 -1
  226. package/IconUnsort/package.json +1 -1
  227. package/IconUnsortCenter/package.json +1 -1
  228. package/IconUpload/package.json +1 -1
  229. package/IconUser/package.json +1 -1
  230. package/IconVZD/package.json +1 -1
  231. package/IconVideo/package.json +1 -1
  232. package/IconVkontakte/package.json +1 -1
  233. package/IconWarning/package.json +1 -1
  234. package/IconWatch/package.json +1 -1
  235. package/IconWideScreen/package.json +1 -1
  236. package/IconWorld/package.json +1 -1
  237. package/IconWrench/package.json +1 -1
  238. package/IconYandexDzen/package.json +1 -1
  239. package/IconYoutube/package.json +1 -1
  240. package/Informer/package.json +1 -1
  241. package/LayoutCanary/package.json +1 -1
  242. package/Loader/package.json +1 -1
  243. package/MixCard/package.json +1 -1
  244. package/MixFocus/package.json +1 -1
  245. package/MixPopoverAnimate/package.json +1 -1
  246. package/MixPopoverArrow/package.json +1 -1
  247. package/MixSpace/package.json +1 -1
  248. package/MixVisuallyHidden/package.json +1 -1
  249. package/Modal/package.json +1 -1
  250. package/MultiComboboxDeprecated/package.json +1 -1
  251. package/Pagination/package.json +1 -1
  252. package/Popover/package.json +1 -1
  253. package/PortalWithTheme/package.json +1 -1
  254. package/ProgressSpin/package.json +1 -1
  255. package/ProgressStepBarCanary/package.json +1 -1
  256. package/Radio/package.json +1 -1
  257. package/RadioGroup/package.json +1 -1
  258. package/Responses/package.json +1 -1
  259. package/Responses403/package.json +1 -1
  260. package/Responses404/package.json +1 -1
  261. package/Responses500/package.json +1 -1
  262. package/Responses503/package.json +1 -1
  263. package/ResponsesConnectionError/package.json +1 -1
  264. package/ResponsesDeleted/package.json +1 -1
  265. package/ResponsesEmptyBox/package.json +1 -1
  266. package/ResponsesEmptyPockets/package.json +1 -1
  267. package/ResponsesExit/package.json +1 -1
  268. package/ResponsesImage/package.json +1 -1
  269. package/ResponsesImage403/package.json +1 -1
  270. package/ResponsesImage404/package.json +1 -1
  271. package/ResponsesImage500/package.json +1 -1
  272. package/ResponsesImage503/package.json +1 -1
  273. package/ResponsesImageConnectionError/package.json +1 -1
  274. package/ResponsesImageDeleted/package.json +1 -1
  275. package/ResponsesImageEmptyBox/package.json +1 -1
  276. package/ResponsesImageEmptyPockets/package.json +1 -1
  277. package/ResponsesImageNothingFound/package.json +1 -1
  278. package/ResponsesImageSuccess/package.json +1 -1
  279. package/ResponsesNothingFound/package.json +1 -1
  280. package/ResponsesSuccess/package.json +1 -1
  281. package/Select/package.json +1 -1
  282. package/Sidebar/package.json +1 -1
  283. package/Skeleton/package.json +1 -1
  284. package/SliderCanary/package.json +1 -1
  285. package/SnackBar/package.json +1 -1
  286. package/Steps/package.json +1 -1
  287. package/Switch/package.json +1 -1
  288. package/SwitchGroup/package.json +1 -1
  289. package/Table/package.json +1 -1
  290. package/Tabs/package.json +1 -1
  291. package/Tag/package.json +1 -1
  292. package/TagBase/package.json +1 -1
  293. package/Text/package.json +1 -1
  294. package/TextField/package.json +1 -1
  295. package/Theme/package.json +1 -1
  296. package/ThemeToggler/package.json +1 -1
  297. package/Timer/package.json +1 -1
  298. package/Tooltip/package.json +1 -1
  299. package/User/package.json +1 -1
  300. package/UserSelect/package.json +1 -1
  301. package/UserSelectDeprecated/package.json +1 -1
  302. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerCanary.js +5 -1
  303. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYear/DatePickerFieldTypeYear.d.ts +45 -0
  304. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js +75 -0
  305. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYear/helpers.d.ts +46 -0
  306. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYear/helpers.js +53 -0
  307. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.d.ts +82 -0
  308. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js +98 -0
  309. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYearRange/helpers.d.ts +32 -0
  310. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerFieldTypeYearRange/helpers.js +2 -0
  311. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerTypeYear/DatePickerTypeYear.d.ts +2 -0
  312. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerTypeYear/DatePickerTypeYear.js +61 -0
  313. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerTypeYearRange/DatePickerTypeYearRange.d.ts +2 -0
  314. package/__internal__/cjs-src/components/DatePickerCanary/DatePickerTypeYearRange/DatePickerTypeYearRange.js +107 -0
  315. package/__internal__/cjs-src/components/DatePickerCanary/helpers.d.ts +2 -0
  316. package/__internal__/cjs-src/components/DatePickerCanary/helpers.js +3 -1
  317. package/__internal__/cjs-src/components/DatePickerCanary/types.d.ts +2 -2
  318. package/__internal__/cjs-src/components/DatePickerCanary/types.js +2 -0
  319. package/__internal__/cjs-src/components/Table/SelectedOptionsList/TableSelectedOptionsList.css +12 -1
  320. package/__internal__/src/components/DatePickerCanary/DatePickerCanary.js +5 -1
  321. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYear/DatePickerFieldTypeYear.d.ts +45 -0
  322. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js +72 -0
  323. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYear/helpers.d.ts +46 -0
  324. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYear/helpers.js +50 -0
  325. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.d.ts +82 -0
  326. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js +95 -0
  327. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYearRange/helpers.d.ts +32 -0
  328. package/__internal__/src/components/DatePickerCanary/DatePickerFieldTypeYearRange/helpers.js +0 -0
  329. package/__internal__/src/components/DatePickerCanary/DatePickerTypeYear/DatePickerTypeYear.d.ts +2 -0
  330. package/__internal__/src/components/DatePickerCanary/DatePickerTypeYear/DatePickerTypeYear.js +58 -0
  331. package/__internal__/src/components/DatePickerCanary/DatePickerTypeYearRange/DatePickerTypeYearRange.d.ts +2 -0
  332. package/__internal__/src/components/DatePickerCanary/DatePickerTypeYearRange/DatePickerTypeYearRange.js +104 -0
  333. package/__internal__/src/components/DatePickerCanary/helpers.d.ts +2 -0
  334. package/__internal__/src/components/DatePickerCanary/helpers.js +2 -0
  335. package/__internal__/src/components/DatePickerCanary/types.d.ts +2 -2
  336. package/__internal__/src/components/DatePickerCanary/types.js +2 -0
  337. package/__internal__/src/components/Table/SelectedOptionsList/TableSelectedOptionsList.css +12 -1
  338. package/createIcon/package.json +1 -1
  339. package/createResponsesImage/package.json +1 -1
  340. package/package.json +1 -1
  341. package/useBreakpoints/package.json +1 -1
  342. package/useChoiceGroup/package.json +1 -1
  343. package/useChoiceGroupIndexed/package.json +1 -1
  344. package/useClickOutside/package.json +1 -1
  345. package/useComponentSize/package.json +1 -1
  346. package/useDebounce/package.json +1 -1
  347. package/useFlag/package.json +1 -1
  348. package/useForkRef/package.json +1 -1
  349. package/useGlobalKeys/package.json +1 -1
  350. package/useHideElementsInLine/package.json +1 -1
  351. package/useKeys/package.json +1 -1
  352. package/useMutableRef/package.json +1 -1
  353. package/useOverflow/package.json +1 -1
  354. package/usePrevious/package.json +1 -1
  355. package/useRefs/package.json +1 -1
  356. package/useResizeObserved/package.json +1 -1
  357. package/useScrollElements/package.json +1 -1
  358. package/useScrollPosition/package.json +1 -1
  359. package/useSelect/package.json +1 -1
  360. package/useSortSteps/package.json +1 -1
  361. package/useThemeVars/package.json +1 -1
  362. package/useTimer/package.json +1 -1
  363. package/withTooltip/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ import { __assign, __read, __rest } from "tslib";
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
+ import { format, isValid, isWithinInterval, parse } from 'date-fns';
4
+ import { useForkRef } from '../../../hooks/useForkRef/useForkRef';
5
+ import { useMutableRef } from '../../../hooks/useMutableRef/useMutableRef';
6
+ import { maxDateDefault, minDateDefault } from '../../../utils/date';
7
+ import { TextField } from '../../TextField/TextField';
8
+ import { datePickerPropFormatTypeYear, datePickerPropPlaceholderTypeYear, datePickerPropSeparatorDefault, getPartsDate, } from '../helpers';
9
+ import { datePickerErrorTypes } from '../types';
10
+ import { useImask } from './helpers';
11
+ export var DatePickerFieldTypeYear = React.forwardRef(function (props, ref) {
12
+ var _a = props.format, formatProp = _a === void 0 ? datePickerPropFormatTypeYear : _a, _b = props.separator, separator = _b === void 0 ? datePickerPropSeparatorDefault : _b, _c = props.placeholder, placeholder = _c === void 0 ? datePickerPropPlaceholderTypeYear : _c, onChange = props.onChange, onError = props.onError, _d = props.minDate, minDate = _d === void 0 ? minDateDefault : _d, _e = props.maxDate, maxDate = _e === void 0 ? maxDateDefault : _e, value = props.value, inputRefProp = props.inputRef, otherProps = __rest(props, ["format", "separator", "placeholder", "onChange", "onError", "minDate", "maxDate", "value", "inputRef"]);
13
+ var inputRef = useRef(null);
14
+ var onChangeRef = useMutableRef(onChange);
15
+ var _f = __read(useState(value && isValid(value) ? format(value, formatProp) : null), 2), stringValue = _f[0], setStringValue = _f[1];
16
+ var handleChange = useCallback(function (e, stringValue) {
17
+ setStringValue(stringValue);
18
+ var onChange = onChangeRef.current;
19
+ if (onChange) {
20
+ if (!stringValue) {
21
+ onChange({ e: e, value: null });
22
+ return;
23
+ }
24
+ var _a = __read(getPartsDate(stringValue, formatProp, separator, false, ['yyyy']), 1), yyyy = _a[0];
25
+ if (yyyy) {
26
+ var date = parse("" + yyyy, datePickerPropFormatTypeYear, new Date());
27
+ if (!isWithinInterval(date, { start: minDate, end: maxDate })) {
28
+ onError &&
29
+ onError({
30
+ type: datePickerErrorTypes[0],
31
+ stringValue: stringValue,
32
+ yyyy: yyyy,
33
+ date: date
34
+ });
35
+ onChange({ e: e, value: null });
36
+ return;
37
+ }
38
+ onChange({ e: e, value: date });
39
+ }
40
+ else {
41
+ onChange({ e: e, value: null });
42
+ }
43
+ }
44
+ }, [minDate === null || minDate === void 0 ? void 0 : minDate.getTime(), maxDate === null || maxDate === void 0 ? void 0 : maxDate.getTime(), formatProp, separator]);
45
+ useImask(formatProp, separator, inputRef, stringValue, onError);
46
+ // при изменении value, нужно обновить stringValue
47
+ useEffect(function () {
48
+ if (value && isValid(value)) {
49
+ setStringValue(format(value, formatProp));
50
+ }
51
+ else if ((stringValue === null || stringValue === void 0 ? void 0 : stringValue.length) === formatProp.length) {
52
+ // если количество введенных символов меньше чем в формате маски
53
+ // то не нужно мешать вводу с клавиатуры
54
+ // если дата была введена полностью и value пришел null,
55
+ // то можно считать что поле нуждается в очистке
56
+ setStringValue('');
57
+ }
58
+ }, [value === null || value === void 0 ? void 0 : value.getTime()]);
59
+ // задаем маску и сохраняем обьект маски в ref
60
+ // обнавляем при смене формата
61
+ // задаем нативный oninput, так как с маской по другому не будет работать
62
+ // обнавляем oninput при смене handleChange
63
+ useEffect(function () {
64
+ if (inputRef.current) {
65
+ inputRef.current.oninput = function (e) {
66
+ var _a;
67
+ handleChange(e, ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) || '');
68
+ };
69
+ }
70
+ }, [handleChange]);
71
+ return (React.createElement(TextField, __assign({}, otherProps, { type: "text", inputContainerRef: ref, inputRef: useForkRef([inputRef, inputRefProp]), value: stringValue, placeholder: placeholder })));
72
+ });
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+ import { IconComponent, IconPropSize } from '../../../icons/Icon/Icon';
3
+ import { PropsWithHTMLAttributes } from '../../../utils/types/PropsWithHTMLAttributes';
4
+ import { TextFieldPropForm, TextFieldPropSize, TextFieldPropStatus, TextFieldPropView, TextFieldPropWidth } from '../../TextField/TextField';
5
+ import { DatePickerPropOnError } from '../types';
6
+ declare type DatePickerFieldTypeYearPropOnChange = (props: {
7
+ e: Event;
8
+ value: Date | null;
9
+ }) => void;
10
+ export declare type DatePickerFieldTypeYearProps = PropsWithHTMLAttributes<{
11
+ className?: string;
12
+ value?: Date | null;
13
+ onChange?: DatePickerFieldTypeYearPropOnChange;
14
+ onError?: DatePickerPropOnError;
15
+ id?: string;
16
+ name?: string;
17
+ disabled?: boolean;
18
+ size?: TextFieldPropSize;
19
+ view?: TextFieldPropView;
20
+ form?: TextFieldPropForm;
21
+ status?: TextFieldPropStatus;
22
+ width?: TextFieldPropWidth;
23
+ onFocus?: React.FocusEventHandler<HTMLElement>;
24
+ onBlur?: React.FocusEventHandler<HTMLElement>;
25
+ autoFocus?: boolean;
26
+ placeholder?: string;
27
+ leftSide?: string | IconComponent;
28
+ rightSide?: string | IconComponent;
29
+ readOnly?: boolean;
30
+ required?: boolean;
31
+ tabIndex?: number;
32
+ inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;
33
+ ariaLabel?: string;
34
+ iconSize?: IconPropSize;
35
+ children?: never;
36
+ format?: string;
37
+ separator?: string;
38
+ minDate?: Date;
39
+ maxDate?: Date;
40
+ focused?: boolean;
41
+ label?: string;
42
+ caption?: string;
43
+ labelPosition?: 'top' | 'left';
44
+ }, HTMLDivElement>;
45
+ export declare const useImask: (formatProp: string, separator: string, inputRef: React.RefObject<HTMLInputElement>, stringValue: string | null, onError: DatePickerPropOnError | undefined) => void;
46
+ export {};
@@ -0,0 +1,50 @@
1
+ import { __read } from "tslib";
2
+ import { useEffect, useRef } from 'react';
3
+ import { format, isValid, parse } from 'date-fns';
4
+ import IMask from 'imask';
5
+ import { datePickerPropFormatTypeYear, getPartsDate } from '../helpers';
6
+ import { datePickerErrorTypes } from '../types';
7
+ export var useImask = function (formatProp, separator, inputRef, stringValue, onError) {
8
+ var imaskRef = useRef(null);
9
+ // задаем маску и сохраняем обьект маски в ref
10
+ // обнавляем при смене формата
11
+ useEffect(function () {
12
+ if (inputRef.current) {
13
+ imaskRef.current = IMask(inputRef.current, {
14
+ mask: Date,
15
+ pattern: formatProp,
16
+ blocks: {
17
+ yyyy: {
18
+ mask: IMask.MaskedRange,
19
+ from: 1,
20
+ to: 9999
21
+ }
22
+ },
23
+ lazy: true,
24
+ autofix: true,
25
+ format: function (date) { return format(date, formatProp); },
26
+ parse: function (string) { return parse(string, formatProp, new Date()); },
27
+ validate: function (string) {
28
+ var _a = __read(getPartsDate(string, formatProp, separator, false, ['yyyy']), 1), yyyy = _a[0];
29
+ if (yyyy && !isValid(parse("" + yyyy, datePickerPropFormatTypeYear, new Date()))) {
30
+ onError &&
31
+ onError({
32
+ type: datePickerErrorTypes[1],
33
+ stringValue: string,
34
+ yyyy: yyyy
35
+ });
36
+ return false;
37
+ }
38
+ return true;
39
+ }
40
+ });
41
+ }
42
+ }, [formatProp, separator]);
43
+ // Нужно для синхранизации value c Imask,
44
+ // так как value мы можем задать через пропс без самого ввода,
45
+ // и Imask требует ручной синхронихации в этом случае
46
+ useEffect(function () {
47
+ var _a;
48
+ (_a = imaskRef.current) === null || _a === void 0 ? void 0 : _a.updateValue();
49
+ }, [stringValue]);
50
+ };
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ export declare const DatePickerFieldTypeYearRange: React.ForwardRefExoticComponent<Pick<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributes<{
3
+ className?: string | undefined;
4
+ value?: Date | null | undefined;
5
+ onChange?: ((props: {
6
+ e: Event;
7
+ value: Date | null;
8
+ }) => void) | undefined;
9
+ onError?: import("../types").DatePickerPropOnError | undefined;
10
+ id?: string | undefined;
11
+ name?: string | undefined;
12
+ disabled?: boolean | undefined;
13
+ size?: "xs" | "s" | "m" | "l" | undefined;
14
+ view?: "default" | "clear" | undefined;
15
+ form?: "default" | "round" | "brick" | "brickRound" | "roundBrick" | "brickDefault" | "defaultBrick" | "clearRound" | "roundClear" | "clearDefault" | "defaultClear" | "brickClear" | "clearBrick" | "clearClear" | undefined;
16
+ status?: "alert" | "success" | "warning" | undefined;
17
+ width?: "default" | "full" | undefined;
18
+ onFocus?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
19
+ onBlur?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
20
+ autoFocus?: boolean | undefined;
21
+ placeholder?: string | undefined;
22
+ leftSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
23
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
24
+ size?: "xs" | "s" | "m" | undefined;
25
+ }, HTMLSpanElement>> | undefined;
26
+ rightSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
27
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
28
+ size?: "xs" | "s" | "m" | undefined;
29
+ }, HTMLSpanElement>> | undefined;
30
+ readOnly?: boolean | undefined;
31
+ required?: boolean | undefined;
32
+ tabIndex?: number | undefined;
33
+ inputRef?: ((instance: HTMLInputElement | HTMLTextAreaElement | null) => void) | React.RefObject<HTMLInputElement | HTMLTextAreaElement> | null | undefined;
34
+ ariaLabel?: string | undefined;
35
+ iconSize?: "xs" | "s" | "m" | undefined;
36
+ children?: undefined;
37
+ format?: string | undefined;
38
+ separator?: string | undefined;
39
+ minDate?: Date | undefined;
40
+ maxDate?: Date | undefined;
41
+ focused?: boolean | undefined;
42
+ label?: string | undefined;
43
+ caption?: string | undefined;
44
+ labelPosition?: "left" | "top" | undefined;
45
+ }, HTMLDivElement>, "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "view" | "size" | "caption" | "form" | "label" | "width" | "format" | "autoFocus" | "readOnly" | "required" | "status" | "focused" | "ariaLabel" | "labelPosition" | "iconSize" | "separator" | "minDate" | "maxDate"> & {
46
+ onChange?: ((props: {
47
+ e: Event;
48
+ value: import("../../../utils/types/Date").DateRange | null;
49
+ }) => void) | undefined;
50
+ value?: import("../../../utils/types/Date").DateRange | null | undefined;
51
+ startFieldInputRef?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
52
+ endFieldInputRef?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
53
+ startFieldLeftSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
54
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
55
+ size?: "xs" | "s" | "m" | undefined;
56
+ }, HTMLSpanElement>> | undefined;
57
+ startFieldRightSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
58
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
59
+ size?: "xs" | "s" | "m" | undefined;
60
+ }, HTMLSpanElement>> | undefined;
61
+ endFieldLeftSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
62
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
63
+ size?: "xs" | "s" | "m" | undefined;
64
+ }, HTMLSpanElement>> | undefined;
65
+ endFieldRightSide?: string | React.FC<import("../../../utils/types/PropsWithHTMLAttributes").PropsWithHTMLAttributesAndRef<{
66
+ view?: "link" | "alert" | "brand" | "ghost" | "primary" | "secondary" | "success" | "warning" | "disabled" | undefined;
67
+ size?: "xs" | "s" | "m" | undefined;
68
+ }, HTMLSpanElement>> | undefined;
69
+ startFieldRef?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
70
+ endFieldRef?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
71
+ startFieldOnFocus?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
72
+ endFieldOnFocus?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
73
+ startFieldOnBlur?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
74
+ endFieldOnBlur?: ((event: React.FocusEvent<HTMLElement>) => void) | undefined;
75
+ startFocused?: boolean | undefined;
76
+ endFocused?: boolean | undefined;
77
+ id?: string | undefined;
78
+ onChangeCurrentVisibleDate?: ((date: Date) => void) | undefined;
79
+ currentVisibleDate?: Date | undefined;
80
+ startFieldName?: string | undefined;
81
+ endFieldName?: string | undefined;
82
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,95 @@
1
+ import { __assign, __read, __rest } from "tslib";
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import isBefore from 'date-fns/isBefore';
4
+ import isEqual from 'date-fns/isEqual';
5
+ import { FieldCaption } from '../../FieldCaption/FieldCaption';
6
+ import { FieldLabel } from '../../FieldLabel/FieldLabel';
7
+ import { DatePickerFieldTypeYear } from '../DatePickerFieldTypeYear/DatePickerFieldTypeYear';
8
+ import { cnDatePickerMixRangeField } from '../DatePickerMixRangeField/DatePickerMixRangeField';
9
+ import { getFormForEnd, getFormForStart } from '../helpers';
10
+ import { datePickerErrorTypes } from '../types';
11
+ export var DatePickerFieldTypeYearRange = forwardRef(function (props, ref) {
12
+ var _a, _b;
13
+ var className = props.className, _c = props.form, form = _c === void 0 ? 'default' : _c, startFieldInputRef = props.startFieldInputRef, startFieldLeftSide = props.startFieldLeftSide, startFieldRightSide = props.startFieldRightSide, endFieldInputRef = props.endFieldInputRef, endFieldLeftSide = props.endFieldLeftSide, endFieldRightSide = props.endFieldRightSide, _d = props.value, value = _d === void 0 ? [] : _d, onChange = props.onChange, onError = props.onError, startFieldName = props.startFieldName, endFieldName = props.endFieldName, disabled = props.disabled, size = props.size, view = props.view, status = props.status, autoFocus = props.autoFocus, placeholder = props.placeholder, readOnly = props.readOnly, required = props.required, tabIndex = props.tabIndex, ariaLabel = props.ariaLabel, iconSize = props.iconSize, format = props.format, separator = props.separator, minDate = props.minDate, maxDate = props.maxDate, startFieldOnBlur = props.startFieldOnBlur, startFieldOnFocus = props.startFieldOnFocus, endFieldOnBlur = props.endFieldOnBlur, endFieldOnFocus = props.endFieldOnFocus, startFieldRef = props.startFieldRef, endFieldRef = props.endFieldRef, startFocused = props.startFocused, endFocused = props.endFocused, label = props.label, labelPosition = props.labelPosition, caption = props.caption, width = props.width, otherProps = __rest(props, ["className", "form", "startFieldInputRef", "startFieldLeftSide", "startFieldRightSide", "endFieldInputRef", "endFieldLeftSide", "endFieldRightSide", "value", "onChange", "onError", "startFieldName", "endFieldName", "disabled", "size", "view", "status", "autoFocus", "placeholder", "readOnly", "required", "tabIndex", "ariaLabel", "iconSize", "format", "separator", "minDate", "maxDate", "startFieldOnBlur", "startFieldOnFocus", "endFieldOnBlur", "endFieldOnFocus", "startFieldRef", "endFieldRef", "startFocused", "endFocused", "label", "labelPosition", "caption", "width"]);
14
+ var commonProps = {
15
+ className: cnDatePickerMixRangeField('Field'),
16
+ disabled: disabled,
17
+ onError: onError,
18
+ size: size,
19
+ view: view,
20
+ status: status,
21
+ autoFocus: autoFocus,
22
+ placeholder: placeholder,
23
+ readOnly: readOnly,
24
+ required: required,
25
+ tabIndex: tabIndex,
26
+ ariaLabel: ariaLabel,
27
+ iconSize: iconSize,
28
+ format: format,
29
+ separator: separator,
30
+ minDate: minDate,
31
+ maxDate: maxDate
32
+ };
33
+ var _e = __read(useState(value === null || value === void 0 ? void 0 : value[0]), 2), startDate = _e[0], setStartDate = _e[1];
34
+ var _f = __read(useState(value === null || value === void 0 ? void 0 : value[1]), 2), endDate = _f[0], setEndDate = _f[1];
35
+ var eventRef = useRef();
36
+ var handleChange = function (e, ownStartDate, ownEndDate) {
37
+ var start = ownStartDate || startDate;
38
+ var end = ownEndDate || endDate;
39
+ if (!onChange) {
40
+ return;
41
+ }
42
+ if (start && end) {
43
+ if (isBefore(start, end) || isEqual(start, end)) {
44
+ onChange({ e: e, value: [start, end] });
45
+ return;
46
+ }
47
+ onChange({ e: e, value: [start, undefined] });
48
+ onError && onError({ type: datePickerErrorTypes[2], date: [start, end] });
49
+ return;
50
+ }
51
+ if (start) {
52
+ onChange({ e: e, value: [start, undefined] });
53
+ return;
54
+ }
55
+ if (end) {
56
+ onChange({ e: e, value: [undefined, end] });
57
+ return;
58
+ }
59
+ onChange({ e: e, value: null });
60
+ };
61
+ var handleStartDateChange = function (props) {
62
+ var _a;
63
+ if (((_a = props.value) === null || _a === void 0 ? void 0 : _a.getTime()) === (startDate === null || startDate === void 0 ? void 0 : startDate.getTime())) {
64
+ return;
65
+ }
66
+ eventRef.current = props.e;
67
+ setStartDate(props.value);
68
+ };
69
+ var handleEndDateChange = function (props) {
70
+ var _a;
71
+ if (((_a = props.value) === null || _a === void 0 ? void 0 : _a.getTime()) === (endDate === null || endDate === void 0 ? void 0 : endDate.getTime())) {
72
+ return;
73
+ }
74
+ eventRef.current = props.e;
75
+ setEndDate(props.value);
76
+ };
77
+ useEffect(function () {
78
+ if (eventRef.current) {
79
+ handleChange(eventRef.current, startDate, endDate);
80
+ }
81
+ }, [eventRef.current]);
82
+ useEffect(function () {
83
+ setStartDate(value === null || value === void 0 ? void 0 : value[0]);
84
+ }, [(_a = value === null || value === void 0 ? void 0 : value[0]) === null || _a === void 0 ? void 0 : _a.getTime()]);
85
+ useEffect(function () {
86
+ setEndDate(value === null || value === void 0 ? void 0 : value[1]);
87
+ }, [(_b = value === null || value === void 0 ? void 0 : value[1]) === null || _b === void 0 ? void 0 : _b.getTime()]);
88
+ return (React.createElement("div", __assign({}, otherProps, { className: cnDatePickerMixRangeField({ view: view, labelPosition: labelPosition, width: width, size: size }, [className]), ref: ref }),
89
+ label && (React.createElement(FieldLabel, { required: required, className: cnDatePickerMixRangeField('Label', { labelPosition: labelPosition }), size: size }, label)),
90
+ React.createElement("div", { className: cnDatePickerMixRangeField('Body') },
91
+ React.createElement("div", { className: cnDatePickerMixRangeField('Fields') },
92
+ React.createElement(DatePickerFieldTypeYear, __assign({}, commonProps, { inputRef: startFieldInputRef, ref: startFieldRef, leftSide: startFieldLeftSide, rightSide: startFieldRightSide, form: getFormForStart(form), value: startDate, onChange: handleStartDateChange, onFocus: startFieldOnFocus, onBlur: startFieldOnBlur, focused: startFocused, name: startFieldName })),
93
+ React.createElement(DatePickerFieldTypeYear, __assign({}, commonProps, { name: endFieldName, inputRef: endFieldInputRef, ref: endFieldRef, leftSide: endFieldLeftSide, rightSide: endFieldRightSide, form: getFormForEnd(form), value: endDate, onChange: handleEndDateChange, onFocus: endFieldOnFocus, onBlur: endFieldOnBlur, focused: endFocused }))),
94
+ caption && (React.createElement(FieldCaption, { className: cnDatePickerMixRangeField('Caption'), status: status }, caption)))));
95
+ });
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ import { IconComponent } from '../../../icons/Icon/Icon';
3
+ import { DateRange } from '../../../utils/types/Date';
4
+ import { DatePickerFieldTypeYearProps } from '../DatePickerFieldTypeYear/helpers';
5
+ declare type DatePickerFieldTypeYearRangePropOnChange = (props: {
6
+ e: Event;
7
+ value: DateRange | null;
8
+ }) => void;
9
+ export declare type DatePickerFieldTypeYearRangeProps = Omit<DatePickerFieldTypeYearProps, 'onChange' | 'value' | 'inputRef' | 'leftSide' | 'rightSide' | 'id' | 'onFocus' | 'onBlur' | 'name'> & {
10
+ onChange?: DatePickerFieldTypeYearRangePropOnChange;
11
+ value?: DateRange | null;
12
+ startFieldInputRef?: React.Ref<HTMLInputElement>;
13
+ endFieldInputRef?: React.Ref<HTMLInputElement>;
14
+ startFieldLeftSide?: string | IconComponent;
15
+ startFieldRightSide?: string | IconComponent;
16
+ endFieldLeftSide?: string | IconComponent;
17
+ endFieldRightSide?: string | IconComponent;
18
+ startFieldRef?: React.Ref<HTMLDivElement>;
19
+ endFieldRef?: React.Ref<HTMLDivElement>;
20
+ startFieldOnFocus?: React.FocusEventHandler<HTMLElement>;
21
+ endFieldOnFocus?: React.FocusEventHandler<HTMLElement>;
22
+ startFieldOnBlur?: React.FocusEventHandler<HTMLElement>;
23
+ endFieldOnBlur?: React.FocusEventHandler<HTMLElement>;
24
+ startFocused?: boolean;
25
+ endFocused?: boolean;
26
+ id?: string;
27
+ onChangeCurrentVisibleDate?: (date: Date) => void;
28
+ currentVisibleDate?: Date;
29
+ startFieldName?: string;
30
+ endFieldName?: string;
31
+ };
32
+ export {};
@@ -0,0 +1,2 @@
1
+ import { DatePickerTypeComponent } from '../types';
2
+ export declare const DatePickerTypeYear: DatePickerTypeComponent<'year'>;
@@ -0,0 +1,58 @@
1
+ import { __assign, __read, __rest } from "tslib";
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import { addYears, startOfDecade } from 'date-fns';
4
+ import { useClickOutside } from '../../../hooks/useClickOutside/useClickOutside';
5
+ import { useFlag } from '../../../hooks/useFlag/useFlag';
6
+ import { setRef } from '../../../utils/setRef';
7
+ import { DatePickerDropdown } from '../DatePickerDropdown/DatePickerDropdown';
8
+ import { DatePickerFieldTypeYear } from '../DatePickerFieldTypeYear/DatePickerFieldTypeYear';
9
+ import { useCurrentVisibleDate } from '../useCurrentVisibleDate';
10
+ export var DatePickerTypeYear = forwardRef(function (props, ref) {
11
+ var events = props.events, dateTimeView = props.dateTimeView, locale = props.locale, dropdownForm = props.dropdownForm, onFocus = props.onFocus, currentVisibleDateProp = props.currentVisibleDate, onChangeCurrentVisibleDateProp = props.onChangeCurrentVisibleDate, renderAdditionalControls = props.renderAdditionalControls, style = props.style, otherProps = __rest(props, ["events", "dateTimeView", "locale", "dropdownForm", "onFocus", "currentVisibleDate", "onChangeCurrentVisibleDate", "renderAdditionalControls", "style"]);
12
+ var fieldRef = useRef(null);
13
+ var calendarRef = useRef(null);
14
+ var _a = __read(useFlag(false), 2), calendarVisible = _a[0], setCalendarVisible = _a[1];
15
+ var _b = __read(useCurrentVisibleDate(currentVisibleDateProp, onChangeCurrentVisibleDateProp), 2), currentVisibleDate = _b[0], setCurrentVisibleDate = _b[1];
16
+ var _c = __read(useState(), 2), calendarVisibleDate = _c[0], setCalendarVisibleDate = _c[1];
17
+ var onFocusHandler = function (e) {
18
+ onFocus && onFocus(e);
19
+ setCalendarVisible.on();
20
+ };
21
+ useEffect(function () {
22
+ if (ref) {
23
+ setRef(ref, fieldRef.current);
24
+ }
25
+ }, [ref, fieldRef]);
26
+ useEffect(function () {
27
+ if (props.value && props.dateTimeView === 'classic' && calendarVisibleDate) {
28
+ var newVisibleDate = startOfDecade(props.value);
29
+ if (newVisibleDate.getTime() !== calendarVisibleDate.getTime()) {
30
+ setCurrentVisibleDate(newVisibleDate);
31
+ }
32
+ return;
33
+ }
34
+ if (props.value && props.dateTimeView !== 'classic' && calendarVisibleDate) {
35
+ var newVisibleDate = startOfDecade(props.value);
36
+ if (newVisibleDate.getTime() !== calendarVisibleDate.getTime() &&
37
+ newVisibleDate.getTime() !== addYears(calendarVisibleDate, 10).getTime()) {
38
+ setCurrentVisibleDate(newVisibleDate);
39
+ }
40
+ }
41
+ }, [props.value]);
42
+ var handleClose = function () {
43
+ setCalendarVisible.off();
44
+ setCurrentVisibleDate(props.value ? undefined : currentVisibleDateProp);
45
+ };
46
+ useClickOutside({
47
+ isActive: calendarVisible,
48
+ ignoreClicksInsideRefs: [fieldRef, calendarRef],
49
+ handler: handleClose
50
+ });
51
+ return (React.createElement(React.Fragment, null,
52
+ React.createElement(DatePickerFieldTypeYear, __assign({}, otherProps, { ref: fieldRef, onFocus: onFocusHandler, style: style })),
53
+ React.createElement(DatePickerDropdown, { ref: calendarRef, anchorRef: fieldRef, isOpen: calendarVisible, value: props.value || undefined, type: "year", view: dateTimeView, events: events, locale: locale, minDate: props.minDate, maxDate: props.maxDate, currentVisibleDate: currentVisibleDate, form: dropdownForm, onChange: function (params) {
54
+ var _a;
55
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, params);
56
+ handleClose();
57
+ }, renderAdditionalControls: renderAdditionalControls, zIndex: typeof (style === null || style === void 0 ? void 0 : style.zIndex) === 'number' ? style.zIndex + 1 : undefined, onChangeCurrentVisibleDate: setCalendarVisibleDate })));
58
+ });
@@ -0,0 +1,2 @@
1
+ import { DatePickerTypeComponent } from '../types';
2
+ export declare const DatePickerTypeYearRange: DatePickerTypeComponent<'date-range'>;
@@ -0,0 +1,104 @@
1
+ import { __assign, __read, __rest } from "tslib";
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import { addYears, startOfDecade } from 'date-fns';
4
+ import { useClickOutside } from '../../../hooks/useClickOutside/useClickOutside';
5
+ import { useFlag } from '../../../hooks/useFlag/useFlag';
6
+ import { useForkRef } from '../../../hooks/useForkRef/useForkRef';
7
+ import { DatePickerDropdown, } from '../DatePickerDropdown/DatePickerDropdown';
8
+ import { DatePickerFieldTypeYearRange } from '../DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange';
9
+ import { normalizeRangeValue } from '../helpers';
10
+ import { useCurrentVisibleDate } from '../useCurrentVisibleDate';
11
+ export var DatePickerTypeYearRange = forwardRef(function (props, ref) {
12
+ var _a, _b, _c, _d;
13
+ var events = props.events, dateTimeView = props.dateTimeView, locale = props.locale, dropdownForm = props.dropdownForm, onFocus = props.onFocus, onBlur = props.onBlur, leftSide = props.leftSide, rightSide = props.rightSide, style = props.style, currentVisibleDateProp = props.currentVisibleDate, onChangeCurrentVisibleDateProp = props.onChangeCurrentVisibleDate, renderAdditionalControls = props.renderAdditionalControls, inputRef = props.inputRef, name = props.name, fieldProps = __rest(props, ["events", "dateTimeView", "locale", "dropdownForm", "onFocus", "onBlur", "leftSide", "rightSide", "style", "currentVisibleDate", "onChangeCurrentVisibleDate", "renderAdditionalControls", "inputRef", "name"]);
14
+ var startFieldRef = useRef(null);
15
+ var endFieldRef = useRef(null);
16
+ var startFieldInputRef = useRef(null);
17
+ var endFieldInputRef = useRef(null);
18
+ var calendarRef = useRef(null);
19
+ var _e = __read(useState(false), 2), fieldFocused = _e[0], setFieldFocused = _e[1];
20
+ var startFocused = fieldFocused === 'start';
21
+ var endFocused = fieldFocused === 'end';
22
+ var hadleChange = function (_a) {
23
+ var _b, _c, _d, _e;
24
+ var e = _a.e, value = _a.value;
25
+ if (startFocused) {
26
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, { e: e, value: normalizeRangeValue([value, (_c = props === null || props === void 0 ? void 0 : props.value) === null || _c === void 0 ? void 0 : _c[1]]) });
27
+ }
28
+ if (endFocused) {
29
+ (_d = props.onChange) === null || _d === void 0 ? void 0 : _d.call(props, { e: e, value: normalizeRangeValue([(_e = props === null || props === void 0 ? void 0 : props.value) === null || _e === void 0 ? void 0 : _e[0], value]) });
30
+ }
31
+ };
32
+ var _f = __read(useFlag(false), 2), calendarVisible = _f[0], setCalendarVisible = _f[1];
33
+ var _g = __read(useCurrentVisibleDate(currentVisibleDateProp, onChangeCurrentVisibleDateProp), 2), currentVisibleDate = _g[0], setCurrentVisibleDate = _g[1];
34
+ var startFieldOnBlurHandler = function (e) { var _a; return Array.isArray(onBlur) ? (_a = onBlur[0]) === null || _a === void 0 ? void 0 : _a.call(onBlur, e) : onBlur === null || onBlur === void 0 ? void 0 : onBlur(e); };
35
+ var endFieldOnBlurHandler = function (e) { var _a; return Array.isArray(onBlur) ? (_a = onBlur[1]) === null || _a === void 0 ? void 0 : _a.call(onBlur, e) : onBlur === null || onBlur === void 0 ? void 0 : onBlur(e); };
36
+ var startFieldOnFocusHandler = function (e) {
37
+ var _a;
38
+ setFieldFocused('start');
39
+ setCalendarVisible.on();
40
+ Array.isArray(onFocus) ? (_a = onFocus[0]) === null || _a === void 0 ? void 0 : _a.call(onFocus, e) : onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
41
+ };
42
+ var endFieldOnFocusHandler = function (e) {
43
+ var _a;
44
+ setFieldFocused('end');
45
+ setCalendarVisible.on();
46
+ Array.isArray(onFocus) ? (_a = onFocus[1]) === null || _a === void 0 ? void 0 : _a.call(onFocus, e) : onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
47
+ };
48
+ // эфект для того чтобы календарь переключался при вводе с клавиатуры
49
+ useEffect(function () {
50
+ var _a, _b, _c;
51
+ if (((_a = props.value) === null || _a === void 0 ? void 0 : _a[0]) && props.dateTimeView === 'classic' && startFocused) {
52
+ var newVisibleDate = startOfDecade(props.value[0]);
53
+ if (newVisibleDate.getTime() !== (currentVisibleDate === null || currentVisibleDate === void 0 ? void 0 : currentVisibleDate.getTime())) {
54
+ setCurrentVisibleDate(newVisibleDate);
55
+ }
56
+ return;
57
+ }
58
+ if (((_b = props.value) === null || _b === void 0 ? void 0 : _b[0]) && props.dateTimeView !== 'classic' && startFocused) {
59
+ var newVisibleDate = startOfDecade(props.value[0]);
60
+ if (newVisibleDate.getTime() !== (currentVisibleDate === null || currentVisibleDate === void 0 ? void 0 : currentVisibleDate.getTime()) &&
61
+ newVisibleDate.getTime() !==
62
+ (currentVisibleDate && addYears(currentVisibleDate, 10).getTime())) {
63
+ setCurrentVisibleDate(newVisibleDate);
64
+ }
65
+ return;
66
+ }
67
+ if (!((_c = props.value) === null || _c === void 0 ? void 0 : _c[0]) && startFocused) {
68
+ setCurrentVisibleDate(currentVisibleDateProp);
69
+ }
70
+ }, [(_b = (_a = props.value) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.getTime(), calendarVisible, startFocused]);
71
+ useEffect(function () {
72
+ var _a, _b, _c;
73
+ if (((_a = props.value) === null || _a === void 0 ? void 0 : _a[1]) && props.dateTimeView === 'classic' && endFocused) {
74
+ var newVisibleDate = startOfDecade(props.value[1]);
75
+ if (newVisibleDate.getTime() !== (currentVisibleDate === null || currentVisibleDate === void 0 ? void 0 : currentVisibleDate.getTime())) {
76
+ setCurrentVisibleDate(newVisibleDate);
77
+ }
78
+ return;
79
+ }
80
+ if (((_b = props.value) === null || _b === void 0 ? void 0 : _b[1]) && props.dateTimeView !== 'classic' && endFocused) {
81
+ var newVisibleDate = startOfDecade(props.value[1]);
82
+ if (newVisibleDate.getTime() !== (currentVisibleDate === null || currentVisibleDate === void 0 ? void 0 : currentVisibleDate.getTime()) &&
83
+ newVisibleDate.getTime() !==
84
+ (currentVisibleDate && addYears(currentVisibleDate, 10).getTime())) {
85
+ setCurrentVisibleDate(addYears(newVisibleDate, -10));
86
+ }
87
+ return;
88
+ }
89
+ if (!((_c = props.value) === null || _c === void 0 ? void 0 : _c[1]) && endFocused) {
90
+ setCurrentVisibleDate(currentVisibleDateProp);
91
+ }
92
+ }, [(_d = (_c = props.value) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.getTime(), calendarVisible, endFocused]);
93
+ useClickOutside({
94
+ isActive: calendarVisible,
95
+ ignoreClicksInsideRefs: [startFieldRef, endFieldRef, calendarRef],
96
+ handler: function () {
97
+ setFieldFocused(false);
98
+ setCalendarVisible.off();
99
+ }
100
+ });
101
+ return (React.createElement(React.Fragment, null,
102
+ React.createElement(DatePickerFieldTypeYearRange, __assign({}, fieldProps, { style: style, ref: ref, startFieldRef: startFieldRef, endFieldRef: endFieldRef, startFieldInputRef: useForkRef([startFieldInputRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[0]]), endFieldInputRef: useForkRef([endFieldInputRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[1]]), startFieldOnFocus: startFieldOnFocusHandler, endFieldOnFocus: endFieldOnFocusHandler, startFieldLeftSide: Array.isArray(leftSide) ? leftSide === null || leftSide === void 0 ? void 0 : leftSide[0] : leftSide, startFieldRightSide: Array.isArray(rightSide) ? rightSide === null || rightSide === void 0 ? void 0 : rightSide[0] : undefined, endFieldLeftSide: Array.isArray(leftSide) ? leftSide === null || leftSide === void 0 ? void 0 : leftSide[1] : undefined, endFieldRightSide: Array.isArray(rightSide) ? rightSide === null || rightSide === void 0 ? void 0 : rightSide[1] : rightSide, startFieldOnBlur: startFieldOnBlurHandler, endFieldOnBlur: endFieldOnBlurHandler, startFocused: startFocused, endFocused: endFocused, startFieldName: Array.isArray(name) ? name[0] : name + "_start", endFieldName: Array.isArray(name) ? name[1] : name + "_end" })),
103
+ React.createElement(DatePickerDropdown, { type: "year", ref: calendarRef, anchorRef: startFieldRef, isOpen: calendarVisible, onChangeCurrentVisibleDate: setCurrentVisibleDate, currentVisibleDate: currentVisibleDate, value: props.value || undefined, view: dateTimeView, events: events, locale: locale, minDate: props.minDate, maxDate: props.maxDate, form: dropdownForm, onChange: hadleChange, renderAdditionalControls: renderAdditionalControls, zIndex: typeof (style === null || style === void 0 ? void 0 : style.zIndex) === 'number' ? style.zIndex + 1 : undefined })));
104
+ });
@@ -8,6 +8,8 @@ export declare const datePickerPropFormatTypeTime = "HH:mm:ss";
8
8
  export declare const datePickerPropPlaceholderTypeTime = "\u0427\u0427:\u041C\u041C:\u0421\u0421";
9
9
  export declare const datePickerPropFormatTypeDateTime: string;
10
10
  export declare const datePickerPropPlaceholderTypeDateTime: string;
11
+ export declare const datePickerPropFormatTypeYear = "yyyy";
12
+ export declare const datePickerPropPlaceholderTypeYear = "\u0413\u0413\u0413\u0413";
11
13
  export declare const normalizeRangeValue: (dateRange: DateRange) => DateRange;
12
14
  export declare const getMultiplicityTime: (format: string, multiplicityHours: number | undefined, multiplicityMinutes: number | undefined, multiplicitySeconds: number | undefined) => (number | undefined)[];
13
15
  export declare const getTimeEnum: (length: number, multiplicity: number | undefined, startOfUnits: (date: Date) => Date, addUnits: (date: Date, amount: number) => Date, getItemLabel: (date: Date) => string) => string[];
@@ -9,6 +9,8 @@ export var datePickerPropFormatTypeTime = "HH:mm:ss";
9
9
  export var datePickerPropPlaceholderTypeTime = "\u0427\u0427:\u041C\u041C:\u0421\u0421";
10
10
  export var datePickerPropFormatTypeDateTime = datePickerPropFormatTypeDate + " " + datePickerPropFormatTypeTime;
11
11
  export var datePickerPropPlaceholderTypeDateTime = datePickerPropPlaceholderTypeDate + " " + datePickerPropPlaceholderTypeTime;
12
+ export var datePickerPropFormatTypeYear = "yyyy";
13
+ export var datePickerPropPlaceholderTypeYear = "\u0413\u0413\u0413\u0413";
12
14
  export var normalizeRangeValue = function (dateRange) {
13
15
  var _a, _b;
14
16
  if (dateRange[0] && dateRange[1] && ((_a = dateRange[0]) === null || _a === void 0 ? void 0 : _a.getTime()) > ((_b = dateRange[1]) === null || _b === void 0 ? void 0 : _b.getTime())) {
@@ -5,11 +5,11 @@ import { DateRange } from '../../utils/types/Date';
5
5
  import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';
6
6
  import { DateTimeAdditionalControlRenderProp, DateTimePropView } from '../DateTimeCanary/helpers';
7
7
  import { TextFieldPropForm, TextFieldPropSize, TextFieldPropStatus, TextFieldPropView, TextFieldPropWidth } from '../TextField/TextField';
8
- export declare const datePickerPropType: readonly ["date", "date-range", "date-time", "date-time-range", "time"];
8
+ export declare const datePickerPropType: readonly ["date", "date-range", "date-time", "date-time-range", "time", "year", "year-range"];
9
9
  export declare type DatePickerPropType = typeof datePickerPropType[number];
10
10
  export declare const datePickerPropTypeDefault: "date";
11
11
  export declare type DatePickerPropDateTimeView = DateTimePropView;
12
- declare type Range = 'date-range' | 'date-time-range';
12
+ declare type Range = 'date-range' | 'date-time-range' | 'year-range';
13
13
  export declare const datePickerErrorTypes: readonly ["outOfRange", "invalidInputAttempt", "startDateIsGreaterThanEndDate"];
14
14
  export declare type DatePickerPropValue<TYPE extends DatePickerPropType> = (TYPE extends Range ? DateRange : Date) | null;
15
15
  export declare type DatePickerPropOnChange<TYPE extends DatePickerPropType> = (props: {
@@ -4,6 +4,8 @@ export var datePickerPropType = [
4
4
  'date-time',
5
5
  'date-time-range',
6
6
  'time',
7
+ 'year',
8
+ 'year-range',
7
9
  ];
8
10
  export var datePickerPropTypeDefault = datePickerPropType[0];
9
11
  export var datePickerErrorTypes = [