@sis-cc/dotstatsuite-visions 12.48.0 → 12.50.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.
@@ -64,6 +64,7 @@ var CollapseButtons = function CollapseButtons(props) {
64
64
  toggleId = _useState[0],
65
65
  setIsOpen = _useState[1];
66
66
 
67
+ var mapIndexed = R.addIndex(R.map);
67
68
  var collapseFactory = function collapseFactory(_ref) {
68
69
  var action = _ref.action,
69
70
  isSecondLevelClikable = _ref.isSecondLevelClikable,
@@ -77,6 +78,7 @@ var CollapseButtons = function CollapseButtons(props) {
77
78
  return React.createElement(
78
79
  Collapse,
79
80
  {
81
+ key: id,
80
82
  'in': toggleId === id,
81
83
  timeout: 'auto',
82
84
  unmountOnExit: true,
@@ -85,9 +87,9 @@ var CollapseButtons = function CollapseButtons(props) {
85
87
  React.createElement(
86
88
  Paper,
87
89
  { elevation: 10, isMobileView: isMobileView },
88
- R.map(function (item) {
90
+ mapIndexed(function (item, index) {
89
91
  return React.createElement(Item, {
90
- key: R.prop('id')(item),
92
+ key: index + '-' + R.prop('id')(item),
91
93
  testId: testId + '_' + id + '_value_' + R.prop('id')(item),
92
94
  parentId: id,
93
95
  item: item,
@@ -112,14 +114,21 @@ var CollapseButtons = function CollapseButtons(props) {
112
114
  className: cx((_cx = {}, _cx[classes.container] = accessibility, _cx)),
113
115
  tabIndex: 0
114
116
  },
115
- R.map(function (_ref3) {
117
+ mapIndexed(function (_ref3, index) {
116
118
  var id = _ref3.id,
117
119
  label = _ref3.label,
118
120
  _ref3$values = _ref3.values,
119
121
  values = _ref3$values === undefined ? [] : _ref3$values;
120
122
  return React.createElement(
121
123
  Grid,
122
- _extends({ item: true, xs: 12, sm: 12, md: R.nth(nbColumns)(COLUMNS) }, gridButtonsProps, { key: id }),
124
+ _extends({
125
+ item: true,
126
+ xs: 12,
127
+ sm: 12,
128
+ md: R.nth(nbColumns)(COLUMNS)
129
+ }, gridButtonsProps, {
130
+ key: index + '::' + id
131
+ }),
123
132
  React.createElement(
124
133
  Typography,
125
134
  { variant: 'h3' },
@@ -58,7 +58,7 @@ var Item = function Item(_ref) {
58
58
  labelAccessor = _ref.labelAccessor;
59
59
 
60
60
  var classes = useStyles();
61
-
61
+ var mapIndexed = R.addIndex(R.map);
62
62
  return React.createElement(
63
63
  Grid,
64
64
  { className: classes.paperItem },
@@ -95,13 +95,13 @@ var Item = function Item(_ref) {
95
95
  React.createElement(
96
96
  'span',
97
97
  { className: classes.itemSubtitle },
98
- R.map(function (subtopic) {
98
+ mapIndexed(function (subtopic, index) {
99
99
  if (R.not(R.is(Object)(subtopic))) return subtopic;
100
100
  if (R.not(isSecondLevelClikable)) return labelAccessor(subtopic, parentId);
101
101
  var id = R.prop('id')(subtopic);
102
102
  return React.createElement(
103
103
  Typography,
104
- { variant: 'h5', key: id },
104
+ { variant: 'h5', key: id + '::' + index },
105
105
  React.createElement(
106
106
  Link,
107
107
  {
@@ -28,12 +28,16 @@ var CustomPaper = function CustomPaper(_ref) {
28
28
  var _cx, _cx2;
29
29
 
30
30
  var isMobileView = _ref.isMobileView,
31
- children = _ref.children;
31
+ children = _ref.children,
32
+ onClose = _ref.onClose;
32
33
 
33
34
  var classes = useStyles();
34
35
  return React.createElement(
35
36
  Paper,
36
37
  {
38
+ onKeyDown: function onKeyDown(e) {
39
+ if (e.key === 'Escape') onClose();
40
+ },
37
41
  classes: {
38
42
  root: cx(classes.paper, (_cx = {}, _cx[classes.mobileView] = isMobileView, _cx))
39
43
  }
@@ -113,7 +113,8 @@ var CollapsibleTree = function CollapsibleTree(_ref) {
113
113
  endIcon: isAllOpen ? React.createElement(KeyboardArrowUpIcon, { color: 'primary' }) : React.createElement(KeyboardArrowDownIcon, { color: 'primary' }),
114
114
  onClick: function onClick() {
115
115
  return handleCollapse(isAllOpen);
116
- }
116
+ },
117
+ tabIndex: 0
117
118
  },
118
119
  buttonAllOpenLabel
119
120
  ),
@@ -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);
@@ -103,6 +103,7 @@ var CollapseButtons = function CollapseButtons(props) {
103
103
  toggleId = _useState[0],
104
104
  setIsOpen = _useState[1];
105
105
 
106
+ var mapIndexed = R.addIndex(R.map);
106
107
  var collapseFactory = function collapseFactory(_ref) {
107
108
  var action = _ref.action,
108
109
  isSecondLevelClikable = _ref.isSecondLevelClikable,
@@ -116,6 +117,7 @@ var CollapseButtons = function CollapseButtons(props) {
116
117
  return _react2.default.createElement(
117
118
  _Collapse2.default,
118
119
  {
120
+ key: id,
119
121
  'in': toggleId === id,
120
122
  timeout: 'auto',
121
123
  unmountOnExit: true,
@@ -124,9 +126,9 @@ var CollapseButtons = function CollapseButtons(props) {
124
126
  _react2.default.createElement(
125
127
  _Paper2.default,
126
128
  { elevation: 10, isMobileView: isMobileView },
127
- R.map(function (item) {
129
+ mapIndexed(function (item, index) {
128
130
  return _react2.default.createElement(_Item2.default, {
129
- key: R.prop('id')(item),
131
+ key: index + '-' + R.prop('id')(item),
130
132
  testId: testId + '_' + id + '_value_' + R.prop('id')(item),
131
133
  parentId: id,
132
134
  item: item,
@@ -151,14 +153,21 @@ var CollapseButtons = function CollapseButtons(props) {
151
153
  className: (0, _classnames2.default)((_cx = {}, _cx[classes.container] = accessibility, _cx)),
152
154
  tabIndex: 0
153
155
  },
154
- R.map(function (_ref3) {
156
+ mapIndexed(function (_ref3, index) {
155
157
  var id = _ref3.id,
156
158
  label = _ref3.label,
157
159
  _ref3$values = _ref3.values,
158
160
  values = _ref3$values === undefined ? [] : _ref3$values;
159
161
  return _react2.default.createElement(
160
162
  _Grid2.default,
161
- _extends({ item: true, xs: 12, sm: 12, md: R.nth(nbColumns)(COLUMNS) }, gridButtonsProps, { key: id }),
163
+ _extends({
164
+ item: true,
165
+ xs: 12,
166
+ sm: 12,
167
+ md: R.nth(nbColumns)(COLUMNS)
168
+ }, gridButtonsProps, {
169
+ key: index + '::' + id
170
+ }),
162
171
  _react2.default.createElement(
163
172
  _Typography2.default,
164
173
  { variant: 'h3' },
@@ -90,7 +90,7 @@ var Item = function Item(_ref) {
90
90
  labelAccessor = _ref.labelAccessor;
91
91
 
92
92
  var classes = useStyles();
93
-
93
+ var mapIndexed = R.addIndex(R.map);
94
94
  return _react2.default.createElement(
95
95
  _Grid2.default,
96
96
  { className: classes.paperItem },
@@ -127,13 +127,13 @@ var Item = function Item(_ref) {
127
127
  _react2.default.createElement(
128
128
  'span',
129
129
  { className: classes.itemSubtitle },
130
- R.map(function (subtopic) {
130
+ mapIndexed(function (subtopic, index) {
131
131
  if (R.not(R.is(Object)(subtopic))) return subtopic;
132
132
  if (R.not(isSecondLevelClikable)) return labelAccessor(subtopic, parentId);
133
133
  var id = R.prop('id')(subtopic);
134
134
  return _react2.default.createElement(
135
135
  _material.Typography,
136
- { variant: 'h5', key: id },
136
+ { variant: 'h5', key: id + '::' + index },
137
137
  _react2.default.createElement(
138
138
  _Link2.default,
139
139
  {
@@ -51,12 +51,16 @@ var CustomPaper = function CustomPaper(_ref) {
51
51
  var _cx, _cx2;
52
52
 
53
53
  var isMobileView = _ref.isMobileView,
54
- children = _ref.children;
54
+ children = _ref.children,
55
+ onClose = _ref.onClose;
55
56
 
56
57
  var classes = useStyles();
57
58
  return _react2.default.createElement(
58
59
  _Paper2.default,
59
60
  {
61
+ onKeyDown: function onKeyDown(e) {
62
+ if (e.key === 'Escape') onClose();
63
+ },
60
64
  classes: {
61
65
  root: (0, _classnames2.default)(classes.paper, (_cx = {}, _cx[classes.mobileView] = isMobileView, _cx))
62
66
  }
@@ -171,7 +171,8 @@ var CollapsibleTree = function CollapsibleTree(_ref) {
171
171
  endIcon: isAllOpen ? _react2.default.createElement(_KeyboardArrowUp2.default, { color: 'primary' }) : _react2.default.createElement(_KeyboardArrowDown2.default, { color: 'primary' }),
172
172
  onClick: function onClick() {
173
173
  return handleCollapse(isAllOpen);
174
- }
174
+ },
175
+ tabIndex: 0
175
176
  },
176
177
  buttonAllOpenLabel
177
178
  ),
@@ -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.48.0",
3
+ "version": "12.50.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"