@sis-cc/dotstatsuite-visions 12.49.0 → 12.51.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.
@@ -86,7 +86,7 @@ var TabPanel = function TabPanel(props) {
86
86
  id: 'vertical-tabpanel-' + R.prop('index', item),
87
87
  'aria-labelledby': 'vertical-tab-' + R.prop('index', item),
88
88
  className: isNarrow ? classes.tabPanelNarrow : classes.tabPanel,
89
- style: styles
89
+ style: { width: R.prop('width', styles) }
90
90
  }, other),
91
91
  open && React.createElement(
92
92
  Box,
@@ -273,8 +273,9 @@ var DynamicDrawer = function DynamicDrawer(props) {
273
273
 
274
274
  var isHidden = open && isNarrow;
275
275
  var isNotHiddenButton = (!R.isEmpty(allSelection) || !isApplyHiddenNarrow) && isNarrow;
276
+ var isApplyButtonShown = open && !isNarrow;
276
277
  useEffect(function () {
277
- if (open && !isNarrow) {
278
+ if (isApplyButtonShown) {
278
279
  document.body.style.overflow = 'hidden';
279
280
  } else {
280
281
  document.body.style.overflow = '';
@@ -287,7 +288,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
287
288
  return React.createElement(
288
289
  'div',
289
290
  { style: { display: 'flex', flexDirection: 'row' } },
290
- open && !isNarrow && React.createElement(Box, {
291
+ isApplyButtonShown && React.createElement(Box, {
291
292
  onClick: function onClick() {
292
293
  return handleClose();
293
294
  },
@@ -306,7 +307,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
306
307
  orientation: 'vertical',
307
308
  variant: 'scrollable',
308
309
  TabIndicatorProps: { style: { transition: 'none' } },
309
- scrollButtons: false,
310
+ scrollButtons: isApplyButtonShown,
310
311
  value: false,
311
312
  onChange: handleChange,
312
313
  'aria-label': 'filters',
@@ -314,11 +315,10 @@ var DynamicDrawer = function DynamicDrawer(props) {
314
315
  sx: {
315
316
  display: isHidden ? 'none' : 'flex',
316
317
  width: '100%',
317
- height: '100%',
318
+ height: isApplyButtonShown ? R.prop('height', styles) : '100%',
318
319
  borderRight: 1,
319
320
  borderColor: 'divider',
320
- zIndex: 1000,
321
- overflow: 'auto'
321
+ zIndex: 1000
322
322
  }
323
323
  },
324
324
  R.map(function (item) {
@@ -355,7 +355,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
355
355
  disableFocusRipple: true
356
356
  });
357
357
  })(list),
358
- open && !isNarrow && React.createElement(
358
+ isApplyButtonShown && React.createElement(
359
359
  Button,
360
360
  {
361
361
  style: { float: 'bottom', margin: '10px' },
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import * as R from 'ramda';
3
3
  import PropTypes from 'prop-types';
4
- import dateFns from 'date-fns';
4
+ import { compareAsc, compareDesc, isSameYear } from 'date-fns';
5
5
  import Grid from '@mui/material/Grid';
6
6
  import Typography from '@mui/material/Typography';
7
7
  import { numeralFormat } from './lib';
@@ -65,13 +65,13 @@ var Period = function Period(_ref) {
65
65
  availableEnd = availableBoundaries[1];
66
66
 
67
67
  if (id === 'year') {
68
- if (dateFns.isSameYear(date, availableStart)) {
68
+ if (isSameYear(date, availableStart)) {
69
69
  date = availableStart;
70
- } else if (dateFns.isSameYear(date, availableEnd)) {
70
+ } else if (isSameYear(date, availableEnd)) {
71
71
  date = availableEnd;
72
72
  }
73
73
  }
74
- return dateFns.compareAsc(date, availableStart) === -1 || dateFns.compareDesc(date, availableEnd) === -1;
74
+ return compareAsc(date, availableStart) === -1 || compareDesc(date, availableEnd) === -1;
75
75
  };
76
76
  };
77
77
  var onChangePeriod = function onChangePeriod(getter, id) {
@@ -3,14 +3,14 @@ var _numeralFormat;
3
3
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
4
4
 
5
5
  import * as R from 'ramda';
6
- import dateFns from 'date-fns';
6
+ import { addDays, addMonths, addQuarters, addWeeks, closestTo, endOfISOWeek, endOfISOWeekYear, format, getDaysInMonth, getISOWeeksInYear, getMonth, getYear, isWithinInterval, parseISO, startOfISOWeek, startOfISOWeekYear, startOfYear } from 'date-fns';
7
7
  import numeral from 'numeral';
8
8
  import { YEAR, SEMESTER, QUARTER, MONTH, WEEK, DAY, HOUR, FULL_HOUR, MINUTE, YEARS, SEMESTERS, QUARTERS, MONTHS, WEEKS, DAYS, FULL_HOURS, HOURS, MINUTES, layoutFrequencies, frequencies, defaultOutputValues, formatOrder, defaultfreq } from './constants';
9
9
 
10
10
  var isWeekInPreviousYear = function isWeekInPreviousYear(date) {
11
- var startIsoWeek = dateFns.startOfISOWeek(date);
11
+ var startIsoWeek = startOfISOWeek(date);
12
12
  return R.pipe(R.times(function (n) {
13
- return dateFns.getYear(dateFns.addDays(startIsoWeek, n));
13
+ return getYear(addDays(startIsoWeek, n));
14
14
  }), R.uniq, R.length, R.equals(1))(4);
15
15
  };
16
16
  var supportedFrequenciesKey = R.keys(layoutFrequencies);
@@ -18,7 +18,7 @@ var dec = R.ifElse(R.gte(0), R.identity, R.dec);
18
18
  var addSemesters = function addSemesters() {
19
19
  var semester = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
20
20
  return function (date) {
21
- return dateFns.addMonths(date, R.multiply(6)(dec(Number(semester))));
21
+ return addMonths(date, R.multiply(6)(dec(Number(semester))));
22
22
  };
23
23
  };
24
24
  var getSemesterValue = R.ifElse(R.pipe(Number, R.inc, R.gte(6)), R.always(1), R.always(2));
@@ -35,15 +35,23 @@ var setRange = function setRange(range) {
35
35
  return R.pipe(getRanges, R.prepend(R.prop(prop)(defaultOutputValues)))(R.prop(prop)(range));
36
36
  };
37
37
  };
38
-
38
+ // export const getDestructuringDate = date =>
39
+ // R.pipe(
40
+ // date => format(date, 'yyyy M d H m HH Q I [S]'),
41
+ // R.replace(/S/, R.pipe(date => getMonth(date), getSemesterValue)(date)),
42
+ // R.split(' '),
43
+ // R.ifElse(v => R.equals(R.length(formatOrder), R.length(v)), R.map(Number), R.empty),
44
+ // )(date);
39
45
  export var getDestructuringDate = function getDestructuringDate(date) {
40
- return R.pipe(function (date) {
41
- return dateFns.format(date, 'YYYY M D H m H Q W [S]');
42
- }, R.replace(/S/, R.pipe(function (date) {
43
- return dateFns.getMonth(date);
44
- }, getSemesterValue)(date)), R.split(' '), R.ifElse(function (v) {
46
+ if (!date || isNaN(new Date(date))) return [];
47
+ var validDate = typeof date === 'string' ? parseISO(date) : date;
48
+ return R.pipe(function (d) {
49
+ var semester = getSemesterValue(getMonth(d));
50
+ var formatted = format(d, 'yyyy M d H m HH Q I');
51
+ return formatted + ' ' + semester;
52
+ }, R.split(' '), R.ifElse(function (v) {
45
53
  return R.equals(R.length(formatOrder), R.length(v));
46
- }, R.map(Number), R.empty))(date);
54
+ }, R.map(Number), R.empty))(validDate);
47
55
  };
48
56
 
49
57
  var updateLimit = function updateLimit(value, isSamePeriod, defaultValue) {
@@ -94,28 +102,28 @@ export var getRange = R.curry(function (boundaries, date) {
94
102
 
95
103
  var hoursRange = R.addIndex(R.map)(function (value, index) {
96
104
  var isSamePeriod = R.all(R.identity)([R.nth(index, equalsDays), R.nth(index, equalsMonths), R.nth(index, equalsYears)]);
97
- return updateLimit(R.nth(index)(hours), isSamePeriod, value);
105
+ return updateLimit(R.nth(index, hours), isSamePeriod, value);
98
106
  })([0, 23]);
99
107
 
100
108
  return _ref4 = {}, _ref4[YEARS] = years, _ref4[HOURS] = hoursRange, _ref4[FULL_HOURS] = hoursRange, _ref4[MONTHS] = R.addIndex(R.map)(function (value, index) {
101
109
  return updateLimit(R.nth(index)(months), R.nth(index, equalsYears), value);
102
110
  })([1, 12]), _ref4[WEEKS] = R.addIndex(R.map)(function (value, index) {
103
111
  return updateLimit(R.nth(index)(weeks), R.nth(index, equalsYears), value);
104
- })([1, dateFns.getISOWeeksInYear(date)]), _ref4[SEMESTERS] = R.addIndex(R.map)(function (value, index) {
112
+ })([1, getISOWeeksInYear(date)]), _ref4[SEMESTERS] = R.addIndex(R.map)(function (value, index) {
105
113
  return updateLimit(R.nth(index)(semesters), R.nth(index, equalsYears), value);
106
114
  })([1, 2]), _ref4[QUARTERS] = R.addIndex(R.map)(function (value, index) {
107
115
  return updateLimit(R.nth(index)(quarters), R.nth(index, equalsYears), value);
108
116
  })([1, 4]), _ref4[DAYS] = R.addIndex(R.map)(function (value, index) {
109
117
  var isSamePeriod = R.and(R.nth(index, equalsMonths), R.nth(index, equalsYears));
110
118
  return updateLimit(R.nth(index)(days), isSamePeriod, value);
111
- })([1, dateFns.getDaysInMonth(date)]), _ref4[MINUTES] = R.addIndex(R.map)(function (value, index) {
119
+ })([1, getDaysInMonth(date)]), _ref4[MINUTES] = R.addIndex(R.map)(function (value, index) {
112
120
  var isSamePeriod = R.all(R.identity)([R.nth(index, R.prop('hours')(listEqualsValueFromDate)), R.nth(index, equalsDays), R.nth(index, equalsMonths), R.nth(index, equalsYears)]);
113
121
  return updateLimit(R.nth(index)(minutes), isSamePeriod, value);
114
122
  })([0, 59]), _ref4;
115
123
  });
116
124
 
117
125
  export var getAjustedDate = function getAjustedDate(frequency) {
118
- return R.when(R.always(R.or(R.equals('W', frequency), R.equals('B', frequency))), R.ifElse(isWeekInPreviousYear, dateFns.startOfISOWeek, dateFns.endOfISOWeek));
126
+ return R.when(R.always(R.or(R.equals('W', frequency), R.equals('B', frequency))), R.ifElse(isWeekInPreviousYear, startOfISOWeek, endOfISOWeek));
119
127
  };
120
128
 
121
129
  export var isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)));
@@ -161,25 +169,25 @@ export var getDate = function getDate(type, dateValue, value, isEnd) {
161
169
  var date = new Date(year, R.dec(month), day, hour, minute);
162
170
  if (R.equals(type, 'Q')) {
163
171
  if (R.isEmpty(dateValue) && isEnd) {
164
- return R.pipe(dateFns.startOfYear, R.flip(dateFns.addQuarters)(3))(date);
172
+ return R.pipe(startOfYear, R.flip(addQuarters)(3))(date);
165
173
  }
166
- return R.pipe(dateFns.startOfYear, function (date) {
167
- return dateFns.addQuarters(date, dec(R.propOr(0, QUARTER)(dateValueUpdated)));
174
+ return R.pipe(startOfYear, function (date) {
175
+ return addQuarters(date, dec(R.propOr(0, QUARTER)(dateValueUpdated)));
168
176
  })(date);
169
177
  }
170
178
  if (R.equals(type, 'S')) {
171
- if (R.isEmpty(dateValue) && isEnd) return R.pipe(dateFns.startOfYear, addSemesters(2))(date);
172
- return R.pipe(dateFns.startOfYear, addSemesters(R.prop(SEMESTER)(dateValueUpdated)))(date);
179
+ if (R.isEmpty(dateValue) && isEnd) return R.pipe(startOfYear, addSemesters(2))(date);
180
+ return R.pipe(startOfYear, addSemesters(R.prop(SEMESTER)(dateValueUpdated)))(date);
173
181
  }
174
182
  if (R.or(R.equals(type, 'W'), R.equals(type, 'B'))) {
175
183
  var weekDate = new Date(year, 6, 1, 0, 0, 0, 0);
176
184
  if (R.isEmpty(dateValue)) {
177
- return R.pipe(R.ifElse(R.always(isEnd), dateFns.endOfISOYear, dateFns.startOfISOYear), getAjustedDate(type))(weekDate);
185
+ return R.pipe(R.ifElse(R.always(isEnd), endOfISOWeekYear, startOfISOWeekYear), getAjustedDate(type))(weekDate);
178
186
  }
179
- var weeksInYear = R.dec(dateFns.getISOWeeksInYear(weekDate));
187
+ var weeksInYear = R.dec(getISOWeeksInYear(weekDate));
180
188
  var nbWeeks = R.pipe(R.propOr(0, WEEK), R.dec, R.ifElse(R.lt(weeksInYear), R.always(weeksInYear), R.identity))(dateValueUpdated);
181
- return R.pipe(dateFns.startOfISOYear, function (date) {
182
- return dateFns.addWeeks(date, nbWeeks);
189
+ return R.pipe(startOfISOWeekYear, function (date) {
190
+ return addWeeks(date, nbWeeks);
183
191
  }, R.of, R.map(getAjustedDate(type)), R.head)(weekDate);
184
192
  }
185
193
  return date;
@@ -188,7 +196,10 @@ export var getDate = function getDate(type, dateValue, value, isEnd) {
188
196
  export var getDateInTheRange = function getDateInTheRange(boundaries) {
189
197
  return function (date) {
190
198
  if (R.isNil(date)) return date;
191
- return dateFns.isWithinRange.apply(dateFns, [date].concat(boundaries)) ? date : dateFns.closestTo(date, boundaries);
199
+ var start = boundaries[0],
200
+ end = boundaries[1];
201
+
202
+ return isWithinInterval(date, { start: start, end: end }) ? date : closestTo(date, boundaries);
192
203
  };
193
204
  };
194
205
 
package/es/utils.js CHANGED
@@ -2,7 +2,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
2
2
 
3
3
  import React from 'react';
4
4
  import * as R from 'ramda';
5
- import dateFns from 'date-fns';
5
+ import { addMinutes } from 'date-fns';
6
6
  import * as diacritics from 'diacritics';
7
7
 
8
8
  var spotlightHandler = function spotlightHandler(_ref) {
@@ -67,7 +67,7 @@ export var getIsRtl = function getIsRtl(theme) {
67
67
  };
68
68
  export var newDate = function newDate(stringDate) {
69
69
  var date = new Date(stringDate);
70
- return dateFns.addMinutes(date, date.getTimezoneOffset());
70
+ return addMinutes(date, date.getTimezoneOffset());
71
71
  };
72
72
 
73
73
  export var prepareTerm = R.pipe(diacritics.remove, R.toLower);
@@ -133,7 +133,7 @@ var TabPanel = function TabPanel(props) {
133
133
  id: 'vertical-tabpanel-' + R.prop('index', item),
134
134
  'aria-labelledby': 'vertical-tab-' + R.prop('index', item),
135
135
  className: isNarrow ? classes.tabPanelNarrow : classes.tabPanel,
136
- style: styles
136
+ style: { width: R.prop('width', styles) }
137
137
  }, other),
138
138
  open && _react2.default.createElement(
139
139
  _Box2.default,
@@ -320,8 +320,9 @@ var DynamicDrawer = function DynamicDrawer(props) {
320
320
 
321
321
  var isHidden = open && isNarrow;
322
322
  var isNotHiddenButton = (!R.isEmpty(allSelection) || !isApplyHiddenNarrow) && isNarrow;
323
+ var isApplyButtonShown = open && !isNarrow;
323
324
  (0, _react.useEffect)(function () {
324
- if (open && !isNarrow) {
325
+ if (isApplyButtonShown) {
325
326
  document.body.style.overflow = 'hidden';
326
327
  } else {
327
328
  document.body.style.overflow = '';
@@ -334,7 +335,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
334
335
  return _react2.default.createElement(
335
336
  'div',
336
337
  { style: { display: 'flex', flexDirection: 'row' } },
337
- open && !isNarrow && _react2.default.createElement(_Box2.default, {
338
+ isApplyButtonShown && _react2.default.createElement(_Box2.default, {
338
339
  onClick: function onClick() {
339
340
  return handleClose();
340
341
  },
@@ -353,7 +354,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
353
354
  orientation: 'vertical',
354
355
  variant: 'scrollable',
355
356
  TabIndicatorProps: { style: { transition: 'none' } },
356
- scrollButtons: false,
357
+ scrollButtons: isApplyButtonShown,
357
358
  value: false,
358
359
  onChange: handleChange,
359
360
  'aria-label': 'filters',
@@ -361,11 +362,10 @@ var DynamicDrawer = function DynamicDrawer(props) {
361
362
  sx: {
362
363
  display: isHidden ? 'none' : 'flex',
363
364
  width: '100%',
364
- height: '100%',
365
+ height: isApplyButtonShown ? R.prop('height', styles) : '100%',
365
366
  borderRight: 1,
366
367
  borderColor: 'divider',
367
- zIndex: 1000,
368
- overflow: 'auto'
368
+ zIndex: 1000
369
369
  }
370
370
  },
371
371
  R.map(function (item) {
@@ -402,7 +402,7 @@ var DynamicDrawer = function DynamicDrawer(props) {
402
402
  disableFocusRipple: true
403
403
  });
404
404
  })(list),
405
- open && !isNarrow && _react2.default.createElement(
405
+ isApplyButtonShown && _react2.default.createElement(
406
406
  _.Button,
407
407
  {
408
408
  style: { float: 'bottom', margin: '10px' },
@@ -16,8 +16,6 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
16
16
 
17
17
  var _dateFns = require('date-fns');
18
18
 
19
- var _dateFns2 = _interopRequireDefault(_dateFns);
20
-
21
19
  var _Grid = require('@mui/material/Grid');
22
20
 
23
21
  var _Grid2 = _interopRequireDefault(_Grid);
@@ -96,13 +94,13 @@ var Period = function Period(_ref) {
96
94
  availableEnd = availableBoundaries[1];
97
95
 
98
96
  if (id === 'year') {
99
- if (_dateFns2.default.isSameYear(date, availableStart)) {
97
+ if ((0, _dateFns.isSameYear)(date, availableStart)) {
100
98
  date = availableStart;
101
- } else if (_dateFns2.default.isSameYear(date, availableEnd)) {
99
+ } else if ((0, _dateFns.isSameYear)(date, availableEnd)) {
102
100
  date = availableEnd;
103
101
  }
104
102
  }
105
- return _dateFns2.default.compareAsc(date, availableStart) === -1 || _dateFns2.default.compareDesc(date, availableEnd) === -1;
103
+ return (0, _dateFns.compareAsc)(date, availableStart) === -1 || (0, _dateFns.compareDesc)(date, availableEnd) === -1;
106
104
  };
107
105
  };
108
106
  var onChangePeriod = function onChangePeriod(getter, id) {
@@ -13,8 +13,6 @@ var R = _interopRequireWildcard(_ramda);
13
13
 
14
14
  var _dateFns = require('date-fns');
15
15
 
16
- var _dateFns2 = _interopRequireDefault(_dateFns);
17
-
18
16
  var _numeral = require('numeral');
19
17
 
20
18
  var _numeral2 = _interopRequireDefault(_numeral);
@@ -26,9 +24,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
24
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
27
25
 
28
26
  var isWeekInPreviousYear = function isWeekInPreviousYear(date) {
29
- var startIsoWeek = _dateFns2.default.startOfISOWeek(date);
27
+ var startIsoWeek = (0, _dateFns.startOfISOWeek)(date);
30
28
  return R.pipe(R.times(function (n) {
31
- return _dateFns2.default.getYear(_dateFns2.default.addDays(startIsoWeek, n));
29
+ return (0, _dateFns.getYear)((0, _dateFns.addDays)(startIsoWeek, n));
32
30
  }), R.uniq, R.length, R.equals(1))(4);
33
31
  };
34
32
  var supportedFrequenciesKey = R.keys(_constants.layoutFrequencies);
@@ -36,7 +34,7 @@ var dec = R.ifElse(R.gte(0), R.identity, R.dec);
36
34
  var addSemesters = function addSemesters() {
37
35
  var semester = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
38
36
  return function (date) {
39
- return _dateFns2.default.addMonths(date, R.multiply(6)(dec(Number(semester))));
37
+ return (0, _dateFns.addMonths)(date, R.multiply(6)(dec(Number(semester))));
40
38
  };
41
39
  };
42
40
  var getSemesterValue = R.ifElse(R.pipe(Number, R.inc, R.gte(6)), R.always(1), R.always(2));
@@ -53,15 +51,23 @@ var setRange = function setRange(range) {
53
51
  return R.pipe(getRanges, R.prepend(R.prop(prop)(_constants.defaultOutputValues)))(R.prop(prop)(range));
54
52
  };
55
53
  };
56
-
54
+ // export const getDestructuringDate = date =>
55
+ // R.pipe(
56
+ // date => format(date, 'yyyy M d H m HH Q I [S]'),
57
+ // R.replace(/S/, R.pipe(date => getMonth(date), getSemesterValue)(date)),
58
+ // R.split(' '),
59
+ // R.ifElse(v => R.equals(R.length(formatOrder), R.length(v)), R.map(Number), R.empty),
60
+ // )(date);
57
61
  var getDestructuringDate = exports.getDestructuringDate = function getDestructuringDate(date) {
58
- return R.pipe(function (date) {
59
- return _dateFns2.default.format(date, 'YYYY M D H m H Q W [S]');
60
- }, R.replace(/S/, R.pipe(function (date) {
61
- return _dateFns2.default.getMonth(date);
62
- }, getSemesterValue)(date)), R.split(' '), R.ifElse(function (v) {
62
+ if (!date || isNaN(new Date(date))) return [];
63
+ var validDate = typeof date === 'string' ? (0, _dateFns.parseISO)(date) : date;
64
+ return R.pipe(function (d) {
65
+ var semester = getSemesterValue((0, _dateFns.getMonth)(d));
66
+ var formatted = (0, _dateFns.format)(d, 'yyyy M d H m HH Q I');
67
+ return formatted + ' ' + semester;
68
+ }, R.split(' '), R.ifElse(function (v) {
63
69
  return R.equals(R.length(_constants.formatOrder), R.length(v));
64
- }, R.map(Number), R.empty))(date);
70
+ }, R.map(Number), R.empty))(validDate);
65
71
  };
66
72
 
67
73
  var updateLimit = function updateLimit(value, isSamePeriod, defaultValue) {
@@ -112,28 +118,28 @@ var getRange = exports.getRange = R.curry(function (boundaries, date) {
112
118
 
113
119
  var hoursRange = R.addIndex(R.map)(function (value, index) {
114
120
  var isSamePeriod = R.all(R.identity)([R.nth(index, equalsDays), R.nth(index, equalsMonths), R.nth(index, equalsYears)]);
115
- return updateLimit(R.nth(index)(hours), isSamePeriod, value);
121
+ return updateLimit(R.nth(index, hours), isSamePeriod, value);
116
122
  })([0, 23]);
117
123
 
118
124
  return _ref4 = {}, _ref4[_constants.YEARS] = years, _ref4[_constants.HOURS] = hoursRange, _ref4[_constants.FULL_HOURS] = hoursRange, _ref4[_constants.MONTHS] = R.addIndex(R.map)(function (value, index) {
119
125
  return updateLimit(R.nth(index)(months), R.nth(index, equalsYears), value);
120
126
  })([1, 12]), _ref4[_constants.WEEKS] = R.addIndex(R.map)(function (value, index) {
121
127
  return updateLimit(R.nth(index)(weeks), R.nth(index, equalsYears), value);
122
- })([1, _dateFns2.default.getISOWeeksInYear(date)]), _ref4[_constants.SEMESTERS] = R.addIndex(R.map)(function (value, index) {
128
+ })([1, (0, _dateFns.getISOWeeksInYear)(date)]), _ref4[_constants.SEMESTERS] = R.addIndex(R.map)(function (value, index) {
123
129
  return updateLimit(R.nth(index)(semesters), R.nth(index, equalsYears), value);
124
130
  })([1, 2]), _ref4[_constants.QUARTERS] = R.addIndex(R.map)(function (value, index) {
125
131
  return updateLimit(R.nth(index)(quarters), R.nth(index, equalsYears), value);
126
132
  })([1, 4]), _ref4[_constants.DAYS] = R.addIndex(R.map)(function (value, index) {
127
133
  var isSamePeriod = R.and(R.nth(index, equalsMonths), R.nth(index, equalsYears));
128
134
  return updateLimit(R.nth(index)(days), isSamePeriod, value);
129
- })([1, _dateFns2.default.getDaysInMonth(date)]), _ref4[_constants.MINUTES] = R.addIndex(R.map)(function (value, index) {
135
+ })([1, (0, _dateFns.getDaysInMonth)(date)]), _ref4[_constants.MINUTES] = R.addIndex(R.map)(function (value, index) {
130
136
  var isSamePeriod = R.all(R.identity)([R.nth(index, R.prop('hours')(listEqualsValueFromDate)), R.nth(index, equalsDays), R.nth(index, equalsMonths), R.nth(index, equalsYears)]);
131
137
  return updateLimit(R.nth(index)(minutes), isSamePeriod, value);
132
138
  })([0, 59]), _ref4;
133
139
  });
134
140
 
135
141
  var getAjustedDate = exports.getAjustedDate = function getAjustedDate(frequency) {
136
- return R.when(R.always(R.or(R.equals('W', frequency), R.equals('B', frequency))), R.ifElse(isWeekInPreviousYear, _dateFns2.default.startOfISOWeek, _dateFns2.default.endOfISOWeek));
142
+ return R.when(R.always(R.or(R.equals('W', frequency), R.equals('B', frequency))), R.ifElse(isWeekInPreviousYear, _dateFns.startOfISOWeek, _dateFns.endOfISOWeek));
137
143
  };
138
144
 
139
145
  var isValidNumber = exports.isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)));
@@ -179,25 +185,25 @@ var getDate = exports.getDate = function getDate(type, dateValue, value, isEnd)
179
185
  var date = new Date(year, R.dec(month), day, hour, minute);
180
186
  if (R.equals(type, 'Q')) {
181
187
  if (R.isEmpty(dateValue) && isEnd) {
182
- return R.pipe(_dateFns2.default.startOfYear, R.flip(_dateFns2.default.addQuarters)(3))(date);
188
+ return R.pipe(_dateFns.startOfYear, R.flip(_dateFns.addQuarters)(3))(date);
183
189
  }
184
- return R.pipe(_dateFns2.default.startOfYear, function (date) {
185
- return _dateFns2.default.addQuarters(date, dec(R.propOr(0, _constants.QUARTER)(dateValueUpdated)));
190
+ return R.pipe(_dateFns.startOfYear, function (date) {
191
+ return (0, _dateFns.addQuarters)(date, dec(R.propOr(0, _constants.QUARTER)(dateValueUpdated)));
186
192
  })(date);
187
193
  }
188
194
  if (R.equals(type, 'S')) {
189
- if (R.isEmpty(dateValue) && isEnd) return R.pipe(_dateFns2.default.startOfYear, addSemesters(2))(date);
190
- return R.pipe(_dateFns2.default.startOfYear, addSemesters(R.prop(_constants.SEMESTER)(dateValueUpdated)))(date);
195
+ if (R.isEmpty(dateValue) && isEnd) return R.pipe(_dateFns.startOfYear, addSemesters(2))(date);
196
+ return R.pipe(_dateFns.startOfYear, addSemesters(R.prop(_constants.SEMESTER)(dateValueUpdated)))(date);
191
197
  }
192
198
  if (R.or(R.equals(type, 'W'), R.equals(type, 'B'))) {
193
199
  var weekDate = new Date(year, 6, 1, 0, 0, 0, 0);
194
200
  if (R.isEmpty(dateValue)) {
195
- return R.pipe(R.ifElse(R.always(isEnd), _dateFns2.default.endOfISOYear, _dateFns2.default.startOfISOYear), getAjustedDate(type))(weekDate);
201
+ return R.pipe(R.ifElse(R.always(isEnd), _dateFns.endOfISOWeekYear, _dateFns.startOfISOWeekYear), getAjustedDate(type))(weekDate);
196
202
  }
197
- var weeksInYear = R.dec(_dateFns2.default.getISOWeeksInYear(weekDate));
203
+ var weeksInYear = R.dec((0, _dateFns.getISOWeeksInYear)(weekDate));
198
204
  var nbWeeks = R.pipe(R.propOr(0, _constants.WEEK), R.dec, R.ifElse(R.lt(weeksInYear), R.always(weeksInYear), R.identity))(dateValueUpdated);
199
- return R.pipe(_dateFns2.default.startOfISOYear, function (date) {
200
- return _dateFns2.default.addWeeks(date, nbWeeks);
205
+ return R.pipe(_dateFns.startOfISOWeekYear, function (date) {
206
+ return (0, _dateFns.addWeeks)(date, nbWeeks);
201
207
  }, R.of, R.map(getAjustedDate(type)), R.head)(weekDate);
202
208
  }
203
209
  return date;
@@ -206,7 +212,10 @@ var getDate = exports.getDate = function getDate(type, dateValue, value, isEnd)
206
212
  var getDateInTheRange = exports.getDateInTheRange = function getDateInTheRange(boundaries) {
207
213
  return function (date) {
208
214
  if (R.isNil(date)) return date;
209
- return _dateFns2.default.isWithinRange.apply(_dateFns2.default, [date].concat(boundaries)) ? date : _dateFns2.default.closestTo(date, boundaries);
215
+ var start = boundaries[0],
216
+ end = boundaries[1];
217
+
218
+ return (0, _dateFns.isWithinInterval)(date, { start: start, end: end }) ? date : (0, _dateFns.closestTo)(date, boundaries);
210
219
  };
211
220
  };
212
221
 
package/lib/utils.js CHANGED
@@ -15,8 +15,6 @@ var R = _interopRequireWildcard(_ramda);
15
15
 
16
16
  var _dateFns = require('date-fns');
17
17
 
18
- var _dateFns2 = _interopRequireDefault(_dateFns);
19
-
20
18
  var _diacritics = require('diacritics');
21
19
 
22
20
  var diacritics = _interopRequireWildcard(_diacritics);
@@ -87,7 +85,7 @@ var getIsRtl = exports.getIsRtl = function getIsRtl(theme) {
87
85
  };
88
86
  var newDate = exports.newDate = function newDate(stringDate) {
89
87
  var date = new Date(stringDate);
90
- return _dateFns2.default.addMinutes(date, date.getTimezoneOffset());
88
+ return (0, _dateFns.addMinutes)(date, date.getTimezoneOffset());
91
89
  };
92
90
 
93
91
  var prepareTerm = exports.prepareTerm = R.pipe(diacritics.remove, R.toLower);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-visions",
3
- "version": "12.49.0",
3
+ "version": "12.51.0",
4
4
  "description": "Library of visual components",
5
5
  "author": "OECD",
6
6
  "homepage": "https://visions-qa.siscc.org/#o",
@@ -28,7 +28,8 @@
28
28
  "test:watch": "jest --watch --no-cache",
29
29
  "lint": "eslint src/ --color",
30
30
  "precommit": "lint-staged",
31
- "transform": "npx jscodeshift -t scripts/transform-mui-imports.js demo/"
31
+ "transform": "npx jscodeshift -t scripts/transform-mui-imports.js demo/",
32
+ "upgrade-date-fns": "npx jscodeshift -t scripts/upgrade-date-fns.js src/"
32
33
  },
33
34
  "dependencies": {
34
35
  "@hello-pangea/dnd": "^16.6.0",
@@ -48,7 +49,7 @@
48
49
  "@mui/icons-material": "^5",
49
50
  "@mui/material": "^5",
50
51
  "@mui/styles": "^5",
51
- "date-fns": "^1.30.1",
52
+ "date-fns": "^2.23.0",
52
53
  "numeral": "^2.0.6",
53
54
  "react": "^18",
54
55
  "react-dom": "^18"