@sis-cc/dotstatsuite-visions 15.3.0 → 15.5.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 (192) hide show
  1. package/dist/PeriodPicker/PeriodPicker.js +389 -413
  2. package/dist/PeriodPicker/PeriodPicker.js.map +1 -1
  3. package/dist/assets/{Alert-wimb2tJH.js → Alert-B7ysmRbW.js} +1 -1
  4. package/dist/assets/Alert.stories-CgFHlVZz.js +3 -0
  5. package/dist/assets/{ApiQueries.stories-CEJ_osx7.js → ApiQueries.stories-meEW4xnB.js} +1 -1
  6. package/dist/assets/ArrowForward-CQfYxDiN.js +1 -0
  7. package/dist/assets/{Asterisk-CH4kwcxv.js → Asterisk-C2gXusCC.js} +1 -1
  8. package/dist/assets/{AuthDialog.stories-DwhfnQlE.js → AuthDialog.stories-D2dJGfXj.js} +1 -1
  9. package/dist/assets/{Breadcrumbs.stories-wZ3hCfev.js → Breadcrumbs.stories-BE81TKpy.js} +1 -1
  10. package/dist/assets/{Button-b8tZLURW.js → Button-Bz1undgK.js} +1 -1
  11. package/dist/assets/{Button-8dfSrKp-.js → Button-DWpgT6ue.js} +1 -1
  12. package/dist/assets/{Button.stories-D6GXhk2n.js → Button.stories-CXtAelQ2.js} +1 -1
  13. package/dist/assets/{ButtonBase-DMDOmkj3.js → ButtonBase-BUy0VYil.js} +1 -1
  14. package/dist/assets/{CardContent-CB0t9_Or.js → CardContent-2WJvyKrX.js} +1 -1
  15. package/dist/assets/ChartsConfig.stories-CLugnT-I.js +1 -0
  16. package/dist/assets/{Checkbox-Cd78wVae.js → Checkbox-k_aOrjEL.js} +1 -1
  17. package/dist/assets/{Chips.stories-B8XbsHgK.js → Chips.stories-DLP4l0uG.js} +1 -1
  18. package/dist/assets/{CircularProgress-CGulUrrN.js → CircularProgress-CHpMRbjI.js} +1 -1
  19. package/dist/assets/Close-CVpVQT7e.js +1 -0
  20. package/dist/assets/{Collapse-D3LlmMLj.js → Collapse-a5yJt-kx.js} +1 -1
  21. package/dist/assets/{CollapseButtons.stories-BUXU-c4H.js → CollapseButtons.stories-C1-CR82y.js} +1 -1
  22. package/dist/assets/{CollapsibleTree.stories-BbuuqKUN.js → CollapsibleTree.stories-D2Y33HwM.js} +1 -1
  23. package/dist/assets/{Color-6AOWCN3U-Bk0kE9HD.js → Color-6AOWCN3U-BHmu7yad.js} +1 -1
  24. package/dist/assets/{Contact.stories-BIjHQTe0.js → Contact.stories-CdLEleTO.js} +1 -1
  25. package/dist/assets/{Container-Cn50A3ei.js → Container-BYZOSJrN.js} +1 -1
  26. package/dist/assets/{Cross-rRsGSPN0.js → Cross-CRjqvqkk.js} +1 -1
  27. package/dist/assets/{CustomChip-CIJf2JRM.js → CustomChip-Dtn2vDnr.js} +1 -1
  28. package/dist/assets/{DataEdit-BgDPftAd.js → DataEdit-Bg80OzSY.js} +1 -1
  29. package/dist/assets/DataEdit.stories-CAwe2K_x.js +1 -0
  30. package/dist/assets/{DataFooter.stories-BK4ouGYy.js → DataFooter.stories-CKAi4wCm.js} +1 -1
  31. package/dist/assets/DataHeader.stories-By_HKPKv.js +3 -0
  32. package/dist/assets/{Dataflow.stories-C0t0uK8g.js → Dataflow.stories-C40LZYgx.js} +1 -1
  33. package/dist/assets/{DeleteAllChip.stories-DtZGtlcb.js → DeleteAllChip.stories-BB3_Jkcj.js} +1 -1
  34. package/dist/assets/{Dialog-BM219kIn.js → Dialog-C90mqPvi.js} +1 -1
  35. package/dist/assets/{Divider-D7397PEg.js → Divider-wLdcVh-X.js} +1 -1
  36. package/dist/assets/{DocsRenderer-JROSPFPF-_umAyE7u.js → DocsRenderer-JROSPFPF-BV3hGNVk.js} +5 -5
  37. package/dist/assets/Done-CRoASE2o.js +1 -0
  38. package/dist/assets/DynamicDrawer.stories-DFRKI0ug.js +5 -0
  39. package/dist/assets/{EmojiObjects-BUcr3EHe.js → EmojiObjects-CiSmtcLW.js} +1 -1
  40. package/dist/assets/ExpandLess-DhgWCdoO.js +1 -0
  41. package/dist/assets/ExpandMore-BVAUkSHR.js +1 -0
  42. package/dist/assets/{ExpansionPanel-BTLdoz4F.js → ExpansionPanel-BQsWBvHM.js} +1 -1
  43. package/dist/assets/ExpansionPanel.stories-B_METTob.js +1 -0
  44. package/dist/assets/{FormControlLabel-DkEOB1w-.js → FormControlLabel-LyDoeoFQ.js} +1 -1
  45. package/dist/assets/{Grid-Cp6VJJvm.js → Grid-VscRVRbc.js} +1 -1
  46. package/dist/assets/{GroupedChips.stories-DJK6BHiV.js → GroupedChips.stories-B2hg0RHV.js} +1 -1
  47. package/dist/assets/{Grow-BrpLFwQJ.js → Grow-B1DZX3xX.js} +1 -1
  48. package/dist/assets/HierarchicalFilter.stories-Bx7T7mSa.js +1 -0
  49. package/dist/assets/{IconButton-DvN4zygm.js → IconButton-clDZix3E.js} +1 -1
  50. package/dist/assets/Info-Bjz3PCQv.js +1 -0
  51. package/dist/assets/{Input-D0dFoJCR.js → Input-D5zly4q1.js} +1 -1
  52. package/dist/assets/Input.stories-ChzYk80o.js +1 -0
  53. package/dist/assets/{InputAdornment-V9-Ojnd3.js → InputAdornment-DBXRUhAq.js} +1 -1
  54. package/dist/assets/{InputNumber.stories-BKism4Ol.js → InputNumber.stories-DdcUBOv5.js} +1 -1
  55. package/dist/assets/{KeyboardArrowUp-C8xvKA6C.js → KeyboardArrowUp-BnksIdhx.js} +1 -1
  56. package/dist/assets/{LabelDivider.stories-DnST0otn.js → LabelDivider.stories-D5Lpnput.js} +1 -1
  57. package/dist/assets/Lens-O4kke0Hf.js +1 -0
  58. package/dist/assets/{Link-BJLGKJfY.js → Link-CsRG3qpx.js} +1 -1
  59. package/dist/assets/ListContext-Cp_Gkfyo.js +1 -0
  60. package/dist/assets/{Loading.stories-CtlSvlhY.js → Loading.stories-B9R5k4cC.js} +1 -1
  61. package/dist/assets/{Logo.stories-DRnZ1SVg.js → Logo.stories-4PCUTJoW.js} +1 -1
  62. package/dist/assets/{MenuItem-Bi-sVS3o.js → MenuItem-BksFy3Mx.js} +1 -1
  63. package/dist/assets/{Mode-DkaGesoV.js → Mode-BaiimFXw.js} +1 -1
  64. package/dist/assets/Mode.stories-C7wXL4ts.js +1 -0
  65. package/dist/assets/{NoData-CJLVyMBg.js → NoData-C-W74UjH.js} +1 -1
  66. package/dist/assets/NoData.stories-zMU0CVo6.js +1 -0
  67. package/dist/assets/{Pagination.stories-DYKM-k2W.js → Pagination.stories-x5vKY2go.js} +1 -1
  68. package/dist/assets/{Paper-B5rIxLX0.js → Paper-DUX2XwMD.js} +1 -1
  69. package/dist/assets/PeriodPicker.stories-yMCOhYpC.js +3 -0
  70. package/dist/assets/{Popover-PeROg1Py.js → Popover-nGYYIdpH.js} +1 -1
  71. package/dist/assets/{RadioGroup-D74xrNfW.js → RadioGroup-D5WYfwkv.js} +1 -1
  72. package/dist/assets/{Select-DqS_ehPo.js → Select-B1kGlSZY.js} +1 -1
  73. package/dist/assets/{Select-DU7HWoIe.js → Select-CfHoDKsQ.js} +1 -1
  74. package/dist/assets/Select.stories-D2Au402t.js +1 -0
  75. package/dist/assets/{Share.stories-BRu2HEye.js → Share.stories-DSyRWwN5.js} +1 -1
  76. package/dist/assets/{ShortUrls.stories-_cQ7A63J.js → ShortUrls.stories-DfWnlvf3.js} +1 -1
  77. package/dist/assets/{SisccFooter.stories-4D6NzHh9.js → SisccFooter.stories-naoVgyTG.js} +1 -1
  78. package/dist/assets/{Spotlight-CunY9Wlw.js → Spotlight-D4lScw9H.js} +1 -1
  79. package/dist/assets/Spotlight.stories-Dgl1Hw5f.js +1 -0
  80. package/dist/assets/{SvgIcon-BvNKNRsy.js → SvgIcon-Dnv_kSSN.js} +1 -1
  81. package/dist/assets/{SwitchBase-hphNuSP7.js → SwitchBase-DCdl_8qR.js} +1 -1
  82. package/dist/assets/{TableFooter.stories-CbtoDt9L.js → TableFooter.stories-DWdVAXHG.js} +1 -1
  83. package/dist/assets/{TableHeader.stories-C9uhyMFd.js → TableHeader.stories-D6UorxXN.js} +1 -1
  84. package/dist/assets/TableHtml5.stories-CHoFSKl_.js +6 -0
  85. package/dist/assets/{TableLayout.stories-seHgGmCc.js → TableLayout.stories-CNMjVm2O.js} +2 -2
  86. package/dist/assets/{TablePreview-vTa8u7FB.js → TablePreview-DrU9eX37.js} +1 -1
  87. package/dist/assets/{TablePreview.stories-E5nHu6E1.js → TablePreview.stories-CJpEvmdA.js} +1 -1
  88. package/dist/assets/{TableRow-DPtXaoT6.js → TableRow-rdoZFi9L.js} +1 -1
  89. package/dist/assets/{Tabs-kXxeQsWO.js → Tabs-aGPKNEBz.js} +1 -1
  90. package/dist/assets/{Tag-GQr-EEXe.js → Tag-aHEEPfRT.js} +1 -1
  91. package/dist/assets/{Tag.stories-DvrNY4SI.js → Tag.stories-D9q4sQtL.js} +1 -1
  92. package/dist/assets/{TextField-D-fzvlRq.js → TextField-CNuuXcD0.js} +1 -1
  93. package/dist/assets/{TextareaAutosize-DUwxARXH.js → TextareaAutosize-DvZwhJ_k.js} +1 -1
  94. package/dist/assets/{ToggleButton-BxLVV5QS.js → ToggleButton-PbEt3mxk.js} +1 -1
  95. package/dist/assets/ToggleButton.stories-B6XNrRjv.js +1 -0
  96. package/dist/assets/{Tooltip-BK38SsMu.js → Tooltip-CjtAZuq8.js} +1 -1
  97. package/dist/assets/{Tooltip-T6OeUQPP.js → Tooltip-M4JOXWnU.js} +1 -1
  98. package/dist/assets/Tooltip.stories-DfyWAeTg.js +1 -0
  99. package/dist/assets/{TransitionGroupContext-B9YNppiq.js → TransitionGroupContext-BtFhXnE5.js} +1 -1
  100. package/dist/assets/{Typography-D2EaSAlt.js → Typography-sKs4TYlw.js} +1 -1
  101. package/dist/assets/{UserRightForm.stories-BMCTkr6j.js → UserRightForm.stories-CjTukXRu.js} +1 -1
  102. package/dist/assets/{VerticalButton-CiZZwHPq.js → VerticalButton-BqJRos3N.js} +1 -1
  103. package/dist/assets/VerticalButton.stories-C5QdhJFu.js +1 -0
  104. package/dist/assets/VirtualizedTree-C02mEbIW.js +9 -0
  105. package/dist/assets/VirtualizedTree.stories-DdbJGO7u.js +3 -0
  106. package/dist/assets/{Warning-bRpCSCwl.js → Warning-ZyaQ9vON.js} +1 -1
  107. package/dist/assets/{WithTooltip-7X4HQR7L-BWbhTf0L.js → WithTooltip-7X4HQR7L-DQ_uUoE6.js} +1 -1
  108. package/dist/assets/and-CXiINtOh.js +1 -0
  109. package/dist/assets/{axe-D4-kGytp.js → axe-Bo7qkgTD.js} +1 -1
  110. package/dist/assets/client-BJp5uP1r.js +9 -0
  111. package/dist/assets/concat-CGZl_DBm.js +1 -0
  112. package/dist/assets/{createSvgIcon-CljDJNRs.js → createSvgIcon-Dn_toqwW.js} +1 -1
  113. package/dist/assets/{dividerClasses-Cw2O4YMA.js → dividerClasses-BjiJz4LE.js} +1 -1
  114. package/dist/assets/{formControlState-B1HWqPHY.js → formControlState-CshUDQr8.js} +1 -1
  115. package/dist/assets/formatter-L2YTDE3Q-BzcXAjUR.js +1 -0
  116. package/dist/assets/{getThemeProps-Ucr-hQd1.js → getThemeProps-ByhGL4i6.js} +1 -1
  117. package/dist/assets/{iframe-BChTFv2E.js → iframe-CzJRHvlf.js} +174 -174
  118. package/dist/assets/index-B3j_sLLf.js +1 -0
  119. package/dist/assets/{index-DNrsnh5y.js → index-BIUG3e7h.js} +1 -1
  120. package/dist/assets/{index-nV5jTrln.js → index-C02bkLOA.js} +1 -1
  121. package/dist/assets/index-DnHbabCA.js +1 -0
  122. package/dist/assets/{index-BHK5vcJo.js → index-k_kDk_WX.js} +1 -1
  123. package/dist/assets/{isMuiElement-CM3cRieD.js → isMuiElement-WdoQxf2_.js} +1 -1
  124. package/dist/assets/lensIndex-BH5oMq3_.js +1 -0
  125. package/dist/assets/{listItemTextClasses-B-Xc90sL.js → listItemTextClasses-BhapLEyw.js} +1 -1
  126. package/dist/assets/lt-C_WQfZX0.js +1 -0
  127. package/dist/assets/makeStyles-R9SA2u7h.js +1 -0
  128. package/dist/assets/of-B561A8RS.js +1 -0
  129. package/dist/assets/{react-18-BU0UKVMC.js → react-18-DvlgTd4e.js} +1 -1
  130. package/dist/assets/set-DabmbB83.js +1 -0
  131. package/dist/assets/{styled-DjMMZo2c.js → styled-CPI81tzY.js} +1 -1
  132. package/dist/assets/{syntaxhighlighter-YFXUGROL-CPw6HVhd.js → syntaxhighlighter-YFXUGROL-af3I6XiN.js} +1 -1
  133. package/dist/assets/{useControlled-vebIUmSu.js → useControlled-DYU6fSLS.js} +1 -1
  134. package/dist/assets/{useKeybordEscapeHandler-i-nL2RGn.js → useKeybordEscapeHandler-DTw1BbCS.js} +1 -1
  135. package/dist/assets/{useMediaQuery-BHneWrHr.js → useMediaQuery-BKBnPu82.js} +1 -1
  136. package/dist/assets/{useSlotProps-l_B1k9bn.js → useSlotProps-G0Xca3YM.js} +1 -1
  137. package/dist/assets/useTheme-DKSVXXEE.js +1 -0
  138. package/dist/assets/{useThemeProps-D1h6moAU.js → useThemeProps-kC73ZYPg.js} +1 -1
  139. package/dist/assets/{utils-Brs7bsU1.js → utils-BIEEyPrY.js} +1 -1
  140. package/dist/assets/{utils-DjyKg0Xe.js → utils-BhWyTzyb.js} +1 -1
  141. package/dist/assets/{with-input-BSL2zc3J.js → with-input-BFppMY9U.js} +1 -1
  142. package/dist/assets/{withSpotlight-DQzw8mN9.js → withSpotlight-B7SJ2ySI.js} +1 -1
  143. package/dist/iframe.html +1 -1
  144. package/dist/index.json +1 -1
  145. package/dist/manifests/components.html +3 -3
  146. package/dist/manifests/components.json +4 -4
  147. package/dist/project.json +1 -1
  148. package/package.json +5 -6
  149. package/dist/assets/Alert.stories-DzYIZm49.js +0 -3
  150. package/dist/assets/ArrowForward-C4P-9gJ-.js +0 -1
  151. package/dist/assets/ChartsConfig.stories-CgxA_mdU.js +0 -1
  152. package/dist/assets/Close-DJLPkll4.js +0 -1
  153. package/dist/assets/DataEdit.stories-CE1wOYJk.js +0 -1
  154. package/dist/assets/DataHeader.stories-BhN9s2qP.js +0 -3
  155. package/dist/assets/Done-CIoepzEw.js +0 -1
  156. package/dist/assets/DynamicDrawer.stories-C4vL5LvP.js +0 -5
  157. package/dist/assets/ExpandLess-6Cz4u0Nt.js +0 -1
  158. package/dist/assets/ExpandMore-ByvumyiN.js +0 -1
  159. package/dist/assets/ExpansionPanel.stories-CX-m96CP.js +0 -1
  160. package/dist/assets/HierarchicalFilter.stories-BTYM2VWp.js +0 -1
  161. package/dist/assets/Info-DtYJYhBL.js +0 -1
  162. package/dist/assets/Input.stories-pfnK5Vvt.js +0 -1
  163. package/dist/assets/Lens-CPIZFy-H.js +0 -1
  164. package/dist/assets/ListContext-BojgVICu.js +0 -1
  165. package/dist/assets/Mode.stories-DaMSysRf.js +0 -1
  166. package/dist/assets/NoData.stories-CZIeN9rh.js +0 -1
  167. package/dist/assets/PeriodPicker.stories-DLjenMFH.js +0 -1
  168. package/dist/assets/Select.stories-B3nRfjtE.js +0 -1
  169. package/dist/assets/Spotlight.stories-C6kCw7Zj.js +0 -1
  170. package/dist/assets/T-Y1RunoT4.js +0 -1
  171. package/dist/assets/TableHtml5.stories-DfZPECvk.js +0 -6
  172. package/dist/assets/ToggleButton.stories-B6LuK6Yh.js +0 -1
  173. package/dist/assets/Tooltip.stories-CQLTNntE.js +0 -1
  174. package/dist/assets/VerticalButton.stories-TV8tj3e4.js +0 -1
  175. package/dist/assets/VirtualizedTree-CgIo97xg.js +0 -9
  176. package/dist/assets/VirtualizedTree.stories-CazUEPj_.js +0 -3
  177. package/dist/assets/client-stwQBlN6.js +0 -1
  178. package/dist/assets/concat-BaCSP4bP.js +0 -1
  179. package/dist/assets/cond-D3AegoZw.js +0 -1
  180. package/dist/assets/forEach-CD9EYxEB.js +0 -1
  181. package/dist/assets/formatter-L2YTDE3Q-MFVZMzss.js +0 -1
  182. package/dist/assets/index-BzWmM-Ic.js +0 -8
  183. package/dist/assets/index-Crconquk.js +0 -1
  184. package/dist/assets/init-D1ASY6bQ.js +0 -1
  185. package/dist/assets/lensIndex-DjJS719w.js +0 -1
  186. package/dist/assets/lt-DLHCA0M9.js +0 -1
  187. package/dist/assets/makeStyles-_Yha3N4h.js +0 -1
  188. package/dist/assets/of-jJbie-2W.js +0 -1
  189. package/dist/assets/prepend-DsY2ekGJ.js +0 -1
  190. package/dist/assets/set-8jiRfFh4.js +0 -1
  191. package/dist/assets/useTheme-sBWMgSZT.js +0 -1
  192. package/dist/assets/zip-QSYbJSwa.js +0 -1
@@ -1,13 +1,12 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import 'react';
3
3
  import * as R from 'ramda';
4
- import { getDaysInMonth, getISOWeeksInYear, parseISO, getMonth, format, startOfYear, addQuarters, endOfISOWeekYear, startOfISOWeekYear, addWeeks, isWithinInterval, closestTo, addMonths, startOfISOWeek, endOfISOWeek, getYear, addDays, isSameYear, compareAsc, compareDesc } from 'date-fns';
4
+ import { min, endOfYear, max, startOfYear, endOfISOWeekYear, startOfISOWeekYear, isWithinInterval, subSeconds, addISOWeekYears, endOfMonth, startOfMonth, endOfDay, startOfDay, endOfHour, startOfHour, isDate, add, sub, getISOWeek, isSameISOWeekYear, getISOWeeksInYear, isSameYear, differenceInYears, isSameQuarter, isSameISOWeek, isSameMonth, isSameDay, isSameHour, isSameMinute, format, getMonth } from 'date-fns';
5
5
  import Grid from '@mui/material/Grid';
6
6
  import Typography from '@mui/material/Typography';
7
7
  import { Button } from '../Button/Button.js';
8
8
  import { Select } from '../Select/Select.js';
9
9
  import makeStyles from '@mui/styles/makeStyles';
10
- import numeral from 'numeral';
11
10
  import { w as withBlank } from '../chunks/utils-kslX1mzh.js';
12
11
 
13
12
  const useStyles = makeStyles((theme) => ({
@@ -30,355 +29,350 @@ const useStyles = makeStyles((theme) => ({
30
29
  },
31
30
  }));
32
31
 
33
- const YEARS = 'years';
34
- const SEMESTERS = 'semesters';
35
- const QUARTERS = 'quarters';
36
- const MONTHS = 'months';
37
- const WEEKS = 'weeks';
38
- const DAYS = 'days';
39
- const FULL_HOURS = 'full_hours';
40
- const HOURS = 'hours';
41
- const MINUTES = 'minutes';
42
- const frequencies = [
43
- YEARS,
44
- MONTHS,
45
- DAYS,
46
- HOURS,
47
- MINUTES,
48
- FULL_HOURS,
49
- QUARTERS,
50
- WEEKS,
51
- SEMESTERS,
52
- ];
53
-
54
32
  const YEAR = 'year';
55
33
  const SEMESTER = 'semester';
56
34
  const QUARTER = 'quarter';
57
35
  const MONTH = 'month';
58
36
  const WEEK = 'week';
59
37
  const DAY = 'day';
60
- const FULL_HOUR = 'full_hour';
61
38
  const HOUR = 'hour';
62
39
  const MINUTE = 'minute';
63
40
 
64
- const layoutFrequencies = {
65
- S: [
66
- [
67
- { values: YEARS, id: YEAR },
68
- { values: SEMESTERS, id: SEMESTER },
69
- ],
70
- ],
71
- A: [[{ values: YEARS, id: YEAR }]],
72
- Q: [
73
- [
74
- { values: YEARS, id: YEAR },
75
- { values: QUARTERS, id: QUARTER },
76
- ],
77
- ],
78
- M: [
79
- [
80
- { values: YEARS, id: YEAR },
81
- { values: MONTHS, id: MONTH },
82
- ],
83
- ],
84
- W: [
85
- [
86
- { values: YEARS, id: YEAR },
87
- { values: WEEKS, id: WEEK },
88
- ],
89
- ],
90
- B: [
91
- [
92
- { values: YEARS, id: YEAR },
93
- { values: WEEKS, id: WEEK },
94
- ],
95
- ],
96
- D: [
97
- [
98
- { values: YEARS, id: YEAR },
99
- { values: MONTHS, id: MONTH },
100
- { values: DAYS, id: DAY },
101
- ],
102
- ],
103
- H: [
104
- [
105
- { values: YEARS, id: YEAR },
106
- { values: MONTHS, id: MONTH },
107
- { values: DAYS, id: DAY },
108
- ],
109
- [{ values: FULL_HOURS, id: FULL_HOUR }],
110
- ],
111
- N: [
112
- [
113
- { values: YEARS, id: YEAR },
114
- { values: MONTHS, id: MONTH },
115
- { values: DAYS, id: DAY },
116
- ],
117
- [
118
- { values: HOURS, id: HOUR },
119
- { values: MINUTES, id: MINUTE },
120
- ],
121
- ],
122
- };
41
+ const defaultfreq = 'A';
123
42
 
124
- const defaultOutputValues = {
125
- [YEARS]: '----',
126
- [SEMESTERS]: '-',
127
- [QUARTERS]: '-',
128
- [MONTHS]: '--',
129
- [WEEKS]: '--',
130
- [DAYS]: '--',
131
- [FULL_HOURS]: '--:00',
132
- [HOURS]: '--',
133
- [MINUTES]: '--',
134
- };
43
+ const getDefaultFrequency = ({ defaultFrequency, frequencies: availableFrequencies }) => {
44
+ const isNotIncludes = !R.includes(defaultFrequency)(availableFrequencies);
135
45
 
136
- const formatOrder = [YEAR, MONTH, DAY, HOUR, MINUTE, FULL_HOUR, QUARTER, WEEK, SEMESTER];
137
- const defaultfreq = 'A';
46
+ return R.or(R.either(R.isEmpty, R.isNil)(defaultFrequency), isNotIncludes)
47
+ ? R.head(availableFrequencies)
48
+ : defaultFrequency;
49
+ };
138
50
 
139
- const isWeekInPreviousYear = (date) => {
140
- const startIsoWeek = startOfISOWeek(date);
141
- return R.pipe(
142
- R.times((n) => getYear(addDays(startIsoWeek, n))),
143
- R.uniq,
144
- R.length,
145
- R.equals(1)
146
- )(4);
51
+ const getFrequencyOptions = (frequencyoptions, frequencyLabels) => {
52
+ const availableFrequencies = R.or(R.isEmpty(frequencyoptions), R.isNil(frequencyoptions))
53
+ ? [defaultfreq]
54
+ : frequencyoptions;
55
+ const options = R.map((option) => ({
56
+ value: option,
57
+ label: R.prop(option, frequencyLabels) || option,
58
+ }))(availableFrequencies);
59
+ if (R.isEmpty(options)) return [{ value: 'A', label: R.propOr('Annual', 'A', frequencyLabels) }];
60
+ return options;
147
61
  };
148
- const supportedFrequenciesKey = R.keys(layoutFrequencies);
149
- const dec = R.ifElse(R.gte(0), R.identity, R.dec);
150
- const addSemesters =
151
- (semester = 0) =>
152
- (date) =>
153
- addMonths(date, R.multiply(6)(dec(Number(semester))));
154
- const getSemesterValue = R.ifElse(R.pipe(Number, R.inc, R.gte(6)), R.always(1), R.always(2));
155
- const getFormat = (value) => numeral(value).format('[0]0');
156
- const getHour = R.pipe(R.pick([HOUR, FULL_HOUR]), R.values, R.head);
157
- const getRanges = (value = [0]) => R.range(R.head(value), R.inc(R.last(value)));
158
- const setRange = (range) => (prop) =>
159
- R.pipe(getRanges, R.prepend(R.prop(prop)(defaultOutputValues)))(R.prop(prop)(range));
160
- // export const getDestructuringDate = date =>
161
- // R.pipe(
162
- // date => format(date, 'yyyy M d H m HH Q I [S]'),
163
- // R.replace(/S/, R.pipe(date => getMonth(date), getSemesterValue)(date)),
164
- // R.split(' '),
165
- // R.ifElse(v => R.equals(R.length(formatOrder), R.length(v)), R.map(Number), R.empty),
166
- // )(date);
167
- const getDestructuringDate = (date) => {
168
- if (!date || isNaN(new Date(date))) return [];
169
- const validDate = typeof date === 'string' ? parseISO(date) : date;
170
- return R.pipe(
171
- (d) => {
172
- const semester = getSemesterValue(getMonth(d));
173
- const formatted = format(d, 'yyyy M d H m HH Q I');
174
- return `${formatted} ${semester}`;
175
- },
176
- R.split(' '),
177
- R.ifElse((v) => R.equals(R.length(formatOrder), R.length(v)), R.map(Number), R.empty)
178
- )(validDate);
62
+
63
+ const multiplyOffset = (offset, factor) => {
64
+ const res = {};
65
+ Object.keys(offset).forEach((k) => (res[k] = offset[k] * factor));
66
+ return res;
179
67
  };
180
68
 
181
- const updateLimit = (value, isSamePeriod, defaultValue) => {
182
- if (isSamePeriod) return value;
183
- return defaultValue;
69
+ const declineDateWithinInterval = (date, interval, offset, validator) => {
70
+ let i = 0;
71
+ let declinedDate = date;
72
+ const domain = [];
73
+ while (isWithinInterval(declinedDate, interval)) {
74
+ domain.push(declinedDate);
75
+ i++;
76
+ declinedDate = add(date, multiplyOffset(offset, i));
77
+ }
78
+ if (!validator(domain[domain.length - 1], interval.end)) {
79
+ domain.push(interval.end);
80
+ }
81
+ i = 1;
82
+ declinedDate = sub(date, offset);
83
+ while (isWithinInterval(declinedDate, interval)) {
84
+ domain.unshift(declinedDate);
85
+ i++;
86
+ declinedDate = sub(date, multiplyOffset(offset, i));
87
+ }
88
+ if (!validator(domain[0], interval.start)) {
89
+ domain.unshift(interval.start);
90
+ }
91
+ return domain;
184
92
  };
185
93
 
186
- const getRange = R.curry((boundaries, date) => {
187
- if (R.isNil(R.head(boundaries)) || R.isNil(R.last(boundaries))) {
188
- return {
189
- [YEARS]: [NaN],
190
- [HOURS]: [NaN],
191
- [FULL_HOURS]: [NaN],
192
- [MONTHS]: [NaN],
193
- [WEEKS]: [NaN],
194
- [SEMESTERS]: [NaN],
195
- [QUARTERS]: [NaN],
196
- [DAYS]: [NaN],
197
- [MINUTES]: [NaN],
198
- };
94
+ const declineISOWeekYears = (allowedInterval, date) => {
95
+ let declinedDate = date;
96
+ const currentISOWeek = getISOWeek(date);
97
+ const domain = [];
98
+ const addISOWeekYear = (d) => {
99
+ if (currentISOWeek === 53) {
100
+ const numberOfWeeksInNextYear = getISOWeeksInYear(add(d, { weeks: 1 }));
101
+ return add(d, { weeks: numberOfWeeksInNextYear });
102
+ }
103
+ const numberOfWeeksInYear = getISOWeeksInYear(d);
104
+ return add(d, { weeks: numberOfWeeksInYear });
105
+ };
106
+ while (isWithinInterval(declinedDate, allowedInterval)) {
107
+ domain.push(declinedDate);
108
+ declinedDate = addISOWeekYear(declinedDate);
199
109
  }
200
- const destructuredDate = getDestructuringDate(date);
201
- const destructuredBoundaries = R.map(getDestructuringDate, boundaries);
202
- const [years, months, days, hours, minutes, , quarters, weeks, semesters] =
203
- R.transpose(destructuredBoundaries);
204
-
205
- if (R.isNil(date)) {
206
- return {
207
- [YEARS]: years,
208
- [HOURS]: [NaN],
209
- [FULL_HOURS]: [NaN],
210
- [MONTHS]: [NaN],
211
- [WEEKS]: [NaN],
212
- [SEMESTERS]: [NaN],
213
- [QUARTERS]: [NaN],
214
- [DAYS]: [NaN],
215
- [MINUTES]: [NaN],
216
- };
110
+ if (!isSameISOWeekYear(domain[domain.length - 1], allowedInterval.end)) {
111
+ domain.push(allowedInterval.end);
217
112
  }
218
- const listEqualsValueFromDate = R.pipe(
219
- R.transpose,
220
- R.reduce((acc, [type, value, start, end]) => {
221
- return { ...acc, [type]: [R.equals(value, start), R.equals(value, end)] };
222
- }, {})
223
- )([frequencies, destructuredDate, ...destructuredBoundaries]);
224
-
225
- const equalsYears = R.prop('years')(listEqualsValueFromDate);
226
- const equalsMonths = R.prop('months')(listEqualsValueFromDate);
227
- const equalsDays = R.prop('days')(listEqualsValueFromDate);
228
-
229
- const hoursRange = R.addIndex(R.map)((value, index) => {
230
- const isSamePeriod = R.all(R.identity)([
231
- R.nth(index, equalsDays),
232
- R.nth(index, equalsMonths),
233
- R.nth(index, equalsYears),
234
- ]);
235
- return updateLimit(R.nth(index, hours), isSamePeriod, value);
236
- })([0, 23]);
237
-
238
- return {
239
- [YEARS]: years,
240
- [HOURS]: hoursRange,
241
- [FULL_HOURS]: hoursRange,
242
- [MONTHS]: R.addIndex(R.map)((value, index) =>
243
- updateLimit(R.nth(index)(months), R.nth(index, equalsYears), value)
244
- )([1, 12]),
245
- [WEEKS]: R.addIndex(R.map)((value, index) =>
246
- updateLimit(R.nth(index)(weeks), R.nth(index, equalsYears), value)
247
- )([1, getISOWeeksInYear(date)]),
248
- [SEMESTERS]: R.addIndex(R.map)((value, index) =>
249
- updateLimit(R.nth(index)(semesters), R.nth(index, equalsYears), value)
250
- )([1, 2]),
251
- [QUARTERS]: R.addIndex(R.map)((value, index) =>
252
- updateLimit(R.nth(index)(quarters), R.nth(index, equalsYears), value)
253
- )([1, 4]),
254
- [DAYS]: R.addIndex(R.map)((value, index) => {
255
- const isSamePeriod = R.and(R.nth(index, equalsMonths), R.nth(index, equalsYears));
256
- return updateLimit(R.nth(index)(days), isSamePeriod, value);
257
- })([1, getDaysInMonth(date)]),
258
- [MINUTES]: R.addIndex(R.map)((value, index) => {
259
- const isSamePeriod = R.all(R.identity)([
260
- R.nth(index, R.prop('hours')(listEqualsValueFromDate)),
261
- R.nth(index, equalsDays),
262
- R.nth(index, equalsMonths),
263
- R.nth(index, equalsYears),
264
- ]);
265
- return updateLimit(R.nth(index)(minutes), isSamePeriod, value);
266
- })([0, 59]),
113
+ const subAYear = (d) => {
114
+ const intoPreviousYear = sub(d, { weeks: currentISOWeek });
115
+ if (currentISOWeek === 53) {
116
+ return intoPreviousYear;
117
+ }
118
+ const numberOfWeeksInPreviousYear = getISOWeeksInYear(intoPreviousYear);
119
+ return sub(intoPreviousYear, { weeks: numberOfWeeksInPreviousYear - currentISOWeek });
267
120
  };
268
- });
121
+ declinedDate = subAYear(date);
122
+ while (isWithinInterval(declinedDate, allowedInterval)) {
123
+ domain.unshift(declinedDate);
124
+ declinedDate = subAYear(declinedDate);
125
+ }
126
+ if (!isSameISOWeekYear(domain[0], allowedInterval.start)) {
127
+ domain.unshift(allowedInterval.start);
128
+ }
129
+ return domain;
130
+ };
269
131
 
270
- const getAjustedDate = (frequency) =>
271
- R.when(
272
- R.always(R.or(R.equals('W', frequency), R.equals('B', frequency))),
273
- R.ifElse(isWeekInPreviousYear, startOfISOWeek, endOfISOWeek)
274
- );
132
+ const optionGetterGenerator = (labelAccessor, validator) => (allowedInterval, value) => {
133
+ const { start, end } = allowedInterval;
134
+ const label = labelAccessor(value);
135
+ if (isDate(value) && !isWithinInterval(value, allowedInterval)) {
136
+ if (validator(value, start)) {
137
+ return { label, value: start };
138
+ }
139
+ if (validator(value, end)) {
140
+ return { label, value: end };
141
+ }
142
+ }
143
+ return { label, value };
144
+ };
275
145
 
276
- const isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)));
277
- const getDefaultFrequency = ({ defaultFrequency, frequencies: availableFrequencies }) => {
278
- const isNotIncludes = R.complement(R.and)(
279
- R.includes(defaultFrequency)(availableFrequencies),
280
- R.includes(defaultFrequency)(supportedFrequenciesKey)
281
- );
282
- return R.or(R.either(R.isEmpty, R.isNil)(defaultFrequency), isNotIncludes)
283
- ? R.head(availableFrequencies)
284
- : defaultFrequency;
146
+ const yearsValuesValidator = (yearsOffset) => (d1, d2) => {
147
+ return yearsOffset === 1 ? isSameYear(d1, d2) : differenceInYears(d1, d2) < yearsOffset;
285
148
  };
286
149
 
287
- const getFrequencyOptions = (frequencyoptions, frequencyLabels) => {
288
- const availableFrequencies = R.or(R.isEmpty(frequencyoptions), R.isNil(frequencyoptions))
289
- ? [defaultfreq]
290
- : R.filter((freq) => R.includes(freq, supportedFrequenciesKey))(frequencyoptions);
291
- const options = R.map((option) => ({ value: option, label: R.prop(option, frequencyLabels) }))(
292
- availableFrequencies
293
- );
294
- if (R.isEmpty(options)) return [{ value: 'A', label: R.propOr('Annual', 'A', frequencyLabels) }];
150
+ const getBlankYearsInputValues = (boundaryInterval, scope = 'start', yearsOffset = 1) => {
151
+ const validator = yearsValuesValidator(yearsOffset);
152
+ const ref =
153
+ scope === 'end' ? endOfYear(boundaryInterval.end) : startOfYear(boundaryInterval.start);
154
+ const domainInterval = { ...boundaryInterval, [scope]: ref };
155
+ const options = declineDateWithinInterval(ref, domainInterval, { years: yearsOffset }, validator);
156
+ const indexToRefine = scope === 'end' ? options.length - 1 : 0;
157
+ options[indexToRefine] = isWithinInterval(options[indexToRefine], boundaryInterval)
158
+ ? options[indexToRefine]
159
+ : boundaryInterval[scope];
295
160
  return options;
296
161
  };
297
162
 
298
- const getLayout = (type, range) => {
299
- const layoutPeriods = R.propOr([], type)(layoutFrequencies);
300
- const hasYear = R.complement(R.isEmpty)(getRanges(range.years));
301
- return R.map(
302
- R.reduce((acc, period) => {
303
- if (hasYear) return R.append(R.evolve({ values: setRange(range) }, period), acc);
304
- return R.append(
305
- R.evolve(
306
- { values: R.pipe(R.flip(R.prop)(defaultOutputValues), R.flip(R.append)([])) },
307
- period
308
- ),
309
- acc
310
- );
311
- }, [])
312
- )(layoutPeriods);
163
+ const getYearsInputValues = (boundaryInterval, current, yearOffset = 1) => {
164
+ const validator = yearsValuesValidator(yearOffset);
165
+ return declineDateWithinInterval(current, boundaryInterval, { years: yearOffset }, validator);
313
166
  };
314
167
 
315
- const getPeriodValue = R.pipe(R.zip(formatOrder), R.fromPairs);
316
-
317
- const getDate = (type, dateValue, value, isEnd) => {
318
- if (R.isNil(value)) return undefined;
319
- const dateValueUpdated = R.pipe(
320
- R.ifElse(R.pipe(getHour, R.isNil), R.identity, R.set(R.lensProp('hour'), getHour(value))),
321
- R.mergeRight(dateValue),
322
- R.over(R.lensProp('month'), R.defaultTo(isEnd ? 12 : 1)),
323
- R.over(R.lensProp('day'), R.defaultTo(isEnd ? 31 : 1)),
324
- R.over(R.lensProp('hour'), R.defaultTo(isEnd ? 23 : 0)),
325
- R.over(R.lensProp('minute'), R.defaultTo(isEnd ? 59 : 0))
326
- )(value);
327
- const { year, month, day, hour, minute } = dateValueUpdated;
328
- const date = new Date(year, R.dec(month), day, hour, minute);
329
- if (R.equals(type, 'Q')) {
330
- if (R.isEmpty(dateValue) && isEnd) {
331
- return R.pipe(startOfYear, R.flip(addQuarters)(3))(date);
168
+ const getYearValueLabel = (value) => (isDate(value) ? format(value, 'yyyy') : '----');
169
+
170
+ const getBlankISOWeekYearsInputValues = (allowedInterval, getter = 'start') => {
171
+ const ref =
172
+ getter === 'end'
173
+ ? endOfISOWeekYear(allowedInterval.end)
174
+ : startOfISOWeekYear(allowedInterval.start);
175
+ const domainInterval = { ...allowedInterval, [getter]: ref };
176
+ let declinedDate = ref;
177
+ const options = [];
178
+ while (isWithinInterval(declinedDate, domainInterval)) {
179
+ if (getter === 'end') {
180
+ options.unshift(declinedDate);
181
+ } else {
182
+ options.push(declinedDate);
332
183
  }
333
- return R.pipe(startOfYear, (startDate) =>
334
- addQuarters(startDate, dec(R.propOr(0, QUARTER)(dateValueUpdated)))
335
- )(date);
336
- }
337
- if (R.equals(type, 'S')) {
338
- if (R.isEmpty(dateValue) && isEnd) return R.pipe(startOfYear, addSemesters(2))(date);
339
- return R.pipe(startOfYear, addSemesters(R.prop(SEMESTER)(dateValueUpdated)))(date);
340
- }
341
- if (R.or(R.equals(type, 'W'), R.equals(type, 'B'))) {
342
- const weekDate = new Date(year, 6, 1, 0, 0, 0, 0);
343
- if (R.isEmpty(dateValue)) {
344
- return R.pipe(
345
- R.ifElse(R.always(isEnd), endOfISOWeekYear, startOfISOWeekYear),
346
- getAjustedDate(type)
347
- )(weekDate);
184
+ if (getter === 'end') {
185
+ declinedDate = startOfISOWeekYear(declinedDate);
186
+ declinedDate = subSeconds(declinedDate, 1);
187
+ } else {
188
+ declinedDate = addISOWeekYears(declinedDate, 1);
348
189
  }
349
- const weeksInYear = R.dec(getISOWeeksInYear(weekDate));
350
- const nbWeeks = R.pipe(
351
- R.propOr(0, WEEK),
352
- R.dec,
353
- R.ifElse(R.lt(weeksInYear), R.always(weeksInYear), R.identity)
354
- )(dateValueUpdated);
355
- return R.pipe(
356
- startOfISOWeekYear,
357
- (startDate) => addWeeks(startDate, nbWeeks),
358
- R.of,
359
- R.map(getAjustedDate(type)),
360
- R.head
361
- )(weekDate);
362
190
  }
363
- return date;
191
+ const indexToRefine = getter === 'end' ? options.length - 1 : 0;
192
+ options[indexToRefine] = isWithinInterval(options[indexToRefine], allowedInterval)
193
+ ? options[indexToRefine]
194
+ : allowedInterval[getter];
195
+ return options;
364
196
  };
365
197
 
366
- const getDateInTheRange = (boundaries) => (date) => {
367
- if (R.isNil(date)) return date;
368
- const [start, end] = boundaries;
369
- return isWithinInterval(date, { start, end }) ? date : closestTo(date, boundaries);
198
+ const getISOWeekYearsInputValues = (boundaryInterval, current) => {
199
+ return declineISOWeekYears(boundaryInterval, current);
370
200
  };
371
201
 
372
- const numeralFormat = {
373
- [YEAR]: R.identity,
374
- [SEMESTER]: R.identity,
375
- [QUARTER]: R.identity,
376
- [MONTH]: getFormat,
377
- [WEEK]: getFormat,
378
- [DAY]: getFormat,
379
- [FULL_HOUR]: R.converge(R.concat, [getFormat, R.always(':00')]),
380
- [HOUR]: getFormat,
381
- [MINUTE]: getFormat,
202
+ const getISOWeekYearValueLabel = (value) => (isDate(value) ? format(value, 'RRRR') : '----');
203
+
204
+ const getSemestersInputValues = (boundaryInterval, current) => {
205
+ const labelAccessor = (d) => (getMonth(d) < 6 ? '01' : '02');
206
+ const validator = (d1, d2) => labelAccessor(d1) === labelAccessor(d2);
207
+ const domainInterval = {
208
+ start: max([startOfYear(current), boundaryInterval.start]),
209
+ end: min([endOfYear(current), boundaryInterval.end]),
210
+ };
211
+ return declineDateWithinInterval(current, domainInterval, { months: 6 }, validator);
212
+ };
213
+
214
+ const getSemesterValueLabel = (value) =>
215
+ isDate(value) ? (getMonth(value) < 6 ? '01' : '02') : '--';
216
+
217
+ const getQuartersInputValues = (boundaryInterval, current) => {
218
+ const domainInterval = {
219
+ start: max([startOfYear(current), boundaryInterval.start]),
220
+ end: min([endOfYear(current), boundaryInterval.end]),
221
+ };
222
+ return declineDateWithinInterval(current, domainInterval, { months: 3 }, isSameQuarter);
223
+ };
224
+
225
+ const getQuarterValueLabel = (value) => (isDate(value) ? format(value, 'QQ') : '--');
226
+
227
+ const getWeeksInputValues = (boundaryInterval, current) => {
228
+ const domainInterval = {
229
+ start: max([startOfISOWeekYear(current), boundaryInterval.start]),
230
+ end: min([endOfISOWeekYear(current), boundaryInterval.end]),
231
+ };
232
+ return declineDateWithinInterval(current, domainInterval, { weeks: 1 }, isSameISOWeek);
233
+ };
234
+
235
+ const getWeekValueLabel = (value) => (isDate(value) ? format(value, 'II') : '--');
236
+
237
+ const getMonthsInputValues = (boundaryInterval, current) => {
238
+ const domainInterval = {
239
+ start: max([startOfYear(current), boundaryInterval.start]),
240
+ end: min([endOfYear(current), boundaryInterval.end]),
241
+ };
242
+ return declineDateWithinInterval(current, domainInterval, { months: 1 }, isSameMonth);
243
+ };
244
+
245
+ const getMonthValueLabel = (value) => (isDate(value) ? format(value, 'MM') : '--');
246
+
247
+ const getDaysInputValues = (boundaryInterval, current) => {
248
+ const domainInterval = {
249
+ start: max([startOfMonth(current), boundaryInterval.start]),
250
+ end: min([endOfMonth(current), boundaryInterval.end]),
251
+ };
252
+ return declineDateWithinInterval(current, domainInterval, { days: 1 }, isSameDay);
253
+ };
254
+
255
+ const getDayValueLabel = (value) => (isDate(value) ? format(value, 'dd') : '--');
256
+
257
+ const getHoursInputValues = (boundaryInterval, current) => {
258
+ const domainInterval = {
259
+ start: max([startOfDay(current), boundaryInterval.start]),
260
+ end: min([endOfDay(current), boundaryInterval.end]),
261
+ };
262
+ return declineDateWithinInterval(current, domainInterval, { hours: 1 }, isSameHour);
263
+ };
264
+
265
+ const getHourValueLabel = (value) => (isDate(value) ? format(value, 'HH') : '--');
266
+
267
+ const getMinutesInputValues = (boundaryInterval, current) => {
268
+ const domainInterval = {
269
+ start: max([startOfHour(current), boundaryInterval.start]),
270
+ end: min([endOfHour(current), boundaryInterval.end]),
271
+ };
272
+ return declineDateWithinInterval(current, domainInterval, { minutes: 1 }, isSameMinute);
273
+ };
274
+
275
+ const getMinuteValueLabel = (value) => (isDate(value) ? format(value, 'mm') : '--');
276
+
277
+ const yearsInputFactoriesGenerator = (yearsOffset) => ({
278
+ id: YEAR,
279
+ valuesGetter: (boundaryInterval, current) =>
280
+ getYearsInputValues(boundaryInterval, current, yearsOffset),
281
+ blankValuesGetter: (boundaryInterval, scope) =>
282
+ getBlankYearsInputValues(boundaryInterval, scope, yearsOffset),
283
+ optionGetter: optionGetterGenerator(getYearValueLabel, yearsValuesValidator(yearsOffset)),
284
+ });
285
+
286
+ const isoWeekYearsInputFactories = {
287
+ id: YEAR,
288
+ valuesGetter: getISOWeekYearsInputValues,
289
+ blankValuesGetter: getBlankISOWeekYearsInputValues,
290
+ optionGetter: optionGetterGenerator(getISOWeekYearValueLabel, isSameISOWeek),
291
+ };
292
+
293
+ const semestersInputFactories = {
294
+ id: SEMESTER,
295
+ valuesGetter: getSemestersInputValues,
296
+ blankValuesGetter: () => [],
297
+ optionGetter: optionGetterGenerator(
298
+ getSemesterValueLabel,
299
+ (d1, d2) => getSemesterValueLabel(d1) === getSemesterValueLabel(d2)
300
+ ),
301
+ };
302
+
303
+ const quartersInputFactories = {
304
+ id: QUARTER,
305
+ valuesGetter: getQuartersInputValues,
306
+ blankValuesGetter: () => [],
307
+ optionGetter: optionGetterGenerator(getQuarterValueLabel, isSameQuarter),
308
+ };
309
+
310
+ const weeksInputFactories = {
311
+ id: WEEK,
312
+ valuesGetter: getWeeksInputValues,
313
+ blankValuesGetter: () => [],
314
+ optionGetter: optionGetterGenerator(getWeekValueLabel, isSameISOWeek),
315
+ };
316
+
317
+ const monthsInputFactories = {
318
+ id: MONTH,
319
+ valuesGetter: getMonthsInputValues,
320
+ blankValuesGetter: () => [],
321
+ optionGetter: optionGetterGenerator(getMonthValueLabel, isSameMonth),
322
+ };
323
+
324
+ const daysInputFactories = {
325
+ id: DAY,
326
+ valuesGetter: getDaysInputValues,
327
+ blankValuesGetter: () => [],
328
+ optionGetter: optionGetterGenerator(getDayValueLabel, isSameDay),
329
+ };
330
+
331
+ const hoursInputFactories = {
332
+ id: HOUR,
333
+ valuesGetter: getHoursInputValues,
334
+ blankValuesGetter: () => [],
335
+ optionGetter: optionGetterGenerator(getHourValueLabel, isSameHour),
336
+ };
337
+
338
+ const minutesInputFactories = {
339
+ id: MINUTE,
340
+ valuesGetter: getMinutesInputValues,
341
+ blankValuesGetter: () => [],
342
+ optionGetter: optionGetterGenerator(getMinuteValueLabel, isSameMinute),
343
+ };
344
+
345
+ const getInputsFactoriesLayout = (freq) => {
346
+ if (freq === 'S') {
347
+ return [[yearsInputFactoriesGenerator(1), semestersInputFactories]];
348
+ }
349
+ if (freq === 'Q') {
350
+ return [[yearsInputFactoriesGenerator(1), quartersInputFactories]];
351
+ }
352
+ if (freq === 'M') {
353
+ return [[yearsInputFactoriesGenerator(1), monthsInputFactories]];
354
+ }
355
+ if (freq === 'W' || freq === 'B') {
356
+ return [[isoWeekYearsInputFactories, weeksInputFactories]];
357
+ }
358
+ if (freq === 'D') {
359
+ return [[yearsInputFactoriesGenerator(1), monthsInputFactories, daysInputFactories]];
360
+ }
361
+ if (freq === 'H') {
362
+ return [
363
+ [yearsInputFactoriesGenerator(1), monthsInputFactories, daysInputFactories],
364
+ [hoursInputFactories],
365
+ ];
366
+ }
367
+ if (freq === 'N') {
368
+ return [
369
+ [yearsInputFactoriesGenerator(1), monthsInputFactories, daysInputFactories],
370
+ [hoursInputFactories, minutesInputFactories],
371
+ ];
372
+ }
373
+ const yearlyMatch = freq.match(/A([\d]+)$/);
374
+ const yearsOffset = yearlyMatch ? Number(yearlyMatch[1]) : 1;
375
+ return [[yearsInputFactoriesGenerator(yearsOffset)]];
382
376
  };
383
377
 
384
378
  const DEFAULT_AVAILABLE_FREQUENCIES = [defaultfreq];
@@ -406,53 +400,40 @@ const CustomPeriodPicker = ({
406
400
  const boundaries = R.defaultTo([], _boundaries);
407
401
  const availableBoundaries = R.defaultTo([], _availableBoundaries);
408
402
  const isPeriodDisabled = R.or(R.any(R.isEmpty)([period, boundaries]), periodDisabled);
409
- const startDate = R.head(period);
410
- const endDate = R.last(period);
411
- const startPeriodBoundaries = [R.head(boundaries), R.defaultTo(R.last(boundaries), endDate)];
412
- const endPeriodBoundaries = [R.defaultTo(R.head(boundaries), startDate), R.last(boundaries)];
413
- const ranges = [
414
- getRange(startPeriodBoundaries, startDate),
415
- getRange(endPeriodBoundaries, endDate)
416
- ];
417
- const showFrequency = R.and(R.gt(R.length(frequencies), 1), R.not(frequencyDisabled));
418
- const destructuringDates = R.map(getDestructuringDate)(period);
419
- const onClickFrequency = (e, value) => {
420
- if (R.is(Function, changeFrequency)) return changeFrequency(value);
403
+ const layoutFrequency = getInputsFactoriesLayout(frequency);
404
+ const boundaryInterval = {
405
+ start: boundaries[0],
406
+ end: boundaries[1]
421
407
  };
422
- const _getIsDisabled = (getter) => (value, id) => {
423
- const fn = R.prop(getter)({ start: R.head, end: R.last });
424
- if (!isValidNumber(Number(value)) || R.length(availableBoundaries) !== 2) {
425
- return false;
426
- }
427
- const dateValue = getPeriodValue(fn(destructuringDates));
428
- let date = getDate(frequency, dateValue, { [id]: Number(value) }, getter === "end");
429
- const [availableStart, availableEnd] = availableBoundaries;
430
- if (id === "year") {
431
- if (isSameYear(date, availableStart)) {
432
- date = availableStart;
433
- } else if (isSameYear(date, availableEnd)) {
434
- date = availableEnd;
435
- }
436
- }
437
- return compareAsc(date, availableStart) === -1 || compareDesc(date, availableEnd) === -1;
408
+ const availableInterval = {
409
+ start: availableBoundaries[0] || boundaries[0],
410
+ end: availableBoundaries[1] || boundaries[1]
411
+ };
412
+ const showFrequency = frequencies.length > 1 && !frequencyDisabled;
413
+ const startAvailableInterval = {
414
+ start: availableInterval.start,
415
+ end: period[1] ? min([period[1], availableInterval.end]) : availableInterval.end
416
+ };
417
+ const endAvailableInterval = {
418
+ start: period[0] ? max([period[0], availableInterval.start]) : availableInterval.start,
419
+ end: availableInterval.end
420
+ };
421
+ const getterAvailableIntervals = {
422
+ start: startAvailableInterval,
423
+ end: endAvailableInterval
438
424
  };
439
- const onChangePeriod = (getter, id) => (value) => {
440
- const fn = R.prop(getter)({ start: R.head, end: R.last });
441
- const lensIndex = R.prop(getter)({ start: R.lensIndex(0), end: R.lensIndex(1) });
442
- const dateValue = getPeriodValue(fn(destructuringDates));
443
- const selectedValue = R.ifElse(
444
- isValidNumber,
445
- R.assoc(id, R.__, {}),
446
- R.always(void 0)
447
- )(Number(value));
448
- const newDate = getDate(frequency, dateValue, selectedValue, getter === "end");
425
+ const onChangePeriod = (getter) => (_value) => {
426
+ const value = _value === "#NULL" ? void 0 : _value;
449
427
  if (R.is(Function, changePeriod)) {
450
- return changePeriod(
451
- R.pipe(R.set(lensIndex, newDate), ([nextStartDate, nextEndDate]) => [
452
- getDateInTheRange(startPeriodBoundaries)(nextStartDate),
453
- getDateInTheRange(endPeriodBoundaries)(nextEndDate)
454
- ])(period)
455
- );
428
+ return changePeriod([
429
+ getter === "start" ? value : period[0],
430
+ getter === "end" ? value : period[1]
431
+ ]);
432
+ }
433
+ };
434
+ const onClickFrequency = (e, value) => {
435
+ if (R.is(Function, changeFrequency)) {
436
+ return changeFrequency(value);
456
437
  }
457
438
  };
458
439
  return /* @__PURE__ */ jsxs(Grid, { "data-testid": "period-picker-test-id", container: true, direction: "row", children: [
@@ -476,62 +457,57 @@ const CustomPeriodPicker = ({
476
457
  ))(frequencies)
477
458
  }
478
459
  ),
479
- R.not(isPeriodDisabled) && /* @__PURE__ */ jsx(Grid, { container: true, item: true, xs: 12, justifyContent: "space-between", children: R.map(({ getter, layout, label, value, testId, getIsDisabled }) => /* @__PURE__ */ jsxs(Grid, { item: true, xs: 5, "data-testid": testId, justifyContent: "space-between", children: [
480
- /* @__PURE__ */ jsx(Grid, { container: true, direction: "row", children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, className: classes.sideLabel, children: /* @__PURE__ */ jsx(Typography, { variant: "body2", tabIndex: 0, "aria-label": label, children: label }) }) }),
481
- /* @__PURE__ */ jsx(Grid, { container: true, direction: "row", children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Grid, { container: true, className: classes.headerContainer, spacing: 1, children: R.map(
482
- (row) => R.map(({ id, values }) => {
483
- const selectedValue = R.isNil(R.prop(id)(value)) ? R.head(values) : R.prop(id)(value);
484
- return /* @__PURE__ */ jsx(
485
- Grid,
486
- {
487
- item: true,
488
- xs: 12 / R.length(row),
489
- className: classes.selectContainer,
490
- children: /* @__PURE__ */ jsx(
491
- Select,
492
- {
493
- onChange: onChangePeriod(getter, id),
494
- label: R.prop(id)(labels),
495
- id: `${id}-${label}`,
496
- dataTestId: `${id}-${label}-test-id`,
497
- value: selectedValue,
498
- disabled: disabled || false,
499
- items: R.map((option) => ({
500
- id,
501
- value: option,
502
- disabled: getIsDisabled(option, id),
503
- label: R.ifElse(
504
- R.is(String),
505
- R.identity,
506
- R.prop(id)(numeralFormat)
507
- )(option)
508
- }))(values)
509
- }
510
- )
511
- },
512
- id
513
- );
514
- })(row)
515
- )(layout) }) }) })
516
- ] }, getter))([
460
+ R.not(isPeriodDisabled) && /* @__PURE__ */ jsx(Grid, { container: true, item: true, xs: 12, justifyContent: "space-between", children: R.map(({ getter, value }) => /* @__PURE__ */ jsxs(
461
+ Grid,
517
462
  {
518
- getter: "start",
519
- testId: "period-picker-start-period-test-id",
520
- layout: getLayout(frequency, R.head(ranges)),
521
- label: R.prop("start")(labels),
522
- value: getPeriodValue(R.head(destructuringDates)),
523
- getIsDisabled: _getIsDisabled("start")
463
+ item: true,
464
+ xs: 5,
465
+ "data-testid": `period-picker-${getter}-period-test-id`,
466
+ justifyContent: "space-between",
467
+ children: [
468
+ /* @__PURE__ */ jsx(Grid, { container: true, direction: "row", children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, className: classes.sideLabel, children: /* @__PURE__ */ jsx(Typography, { variant: "body2", tabIndex: 0, "aria-label": labels[getter] || getter, children: labels[getter] || getter }) }) }),
469
+ /* @__PURE__ */ jsx(Grid, { container: true, direction: "row", children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Grid, { container: true, className: classes.headerContainer, spacing: 1, children: R.map(
470
+ (row) => R.map(({ id, valuesGetter, blankValuesGetter, optionGetter }) => {
471
+ const isInvalid = R.isEmpty(boundaries) || R.isNil(boundaries[0]) || R.isNil(boundaries[1]);
472
+ let values = [];
473
+ if (!isInvalid) {
474
+ values = R.isNil(value) ? blankValuesGetter(boundaryInterval, getter) : valuesGetter(boundaryInterval, value);
475
+ }
476
+ const options = ["#NULL", ...values].map(
477
+ (v) => optionGetter(availableInterval, v)
478
+ );
479
+ return /* @__PURE__ */ jsx(
480
+ Grid,
481
+ {
482
+ item: true,
483
+ xs: 12 / R.length(row),
484
+ className: classes.selectContainer,
485
+ children: /* @__PURE__ */ jsx(
486
+ Select,
487
+ {
488
+ onChange: onChangePeriod(getter),
489
+ label: R.prop(id)(labels),
490
+ id: `${id}-${labels[getter] || getter}`,
491
+ dataTestId: `${id}-${labels[getter] || getter}-test-id`,
492
+ value: value || "#NULL",
493
+ disabled: disabled || false,
494
+ items: options.map((item) => ({
495
+ ...item,
496
+ disabled: !isDate(item.value) || !isWithinInterval(item.value, getterAvailableIntervals[getter])
497
+ }))
498
+ }
499
+ )
500
+ },
501
+ id
502
+ );
503
+ })(row)
504
+ )(layoutFrequency) }) }) })
505
+ ]
524
506
  },
525
- {
526
- getter: "end",
527
- testId: "period-picker-end-period-test-id",
528
- layout: getLayout(
529
- frequency,
530
- R.last(ranges)),
531
- label: R.prop("end")(labels),
532
- value: getPeriodValue(R.last(destructuringDates)),
533
- getIsDisabled: _getIsDisabled("end")
534
- }
507
+ getter
508
+ ))([
509
+ { getter: "start", value: period[0] },
510
+ { getter: "end", value: period[1] }
535
511
  ]) })
536
512
  ] });
537
513
  };