@sis-cc/dotstatsuite-visions 7.22.6 → 7.23.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.
- package/es/Mode/Mode.js +89 -0
- package/es/Mode/index.js +24 -0
- package/es/PeriodPicker/PeriodPicker.js +27 -12
- package/es/PeriodPicker/constants.js +9 -9
- package/es/PeriodPicker/lib.js +3 -6
- package/es/index.js +1 -0
- package/lib/Mode/Mode.js +117 -0
- package/lib/Mode/index.js +16 -0
- package/lib/PeriodPicker/PeriodPicker.js +30 -12
- package/lib/PeriodPicker/constants.js +9 -9
- package/lib/PeriodPicker/lib.js +3 -6
- package/lib/index.js +10 -1
- package/package.json +2 -1
package/es/Mode/Mode.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
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; };
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import * as R from 'ramda';
|
|
6
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
7
|
+
import RadioGroup from '@material-ui/core/RadioGroup';
|
|
8
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
9
|
+
import Radio from '@material-ui/core/Radio';
|
|
10
|
+
import { Tooltip } from '../';
|
|
11
|
+
|
|
12
|
+
var useStyles = makeStyles(function (theme) {
|
|
13
|
+
return {
|
|
14
|
+
title: _extends({
|
|
15
|
+
padding: 0
|
|
16
|
+
}, R.pathOr({}, ['mixins', 'share', 'title'], theme)),
|
|
17
|
+
label: theme.typography.body2,
|
|
18
|
+
icon: {
|
|
19
|
+
marginLeft: theme.spacing(0.5)
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
var Warning = function Warning(_ref) {
|
|
25
|
+
var title = _ref.title,
|
|
26
|
+
children = _ref.children;
|
|
27
|
+
|
|
28
|
+
var classes = useStyles();
|
|
29
|
+
return React.createElement(
|
|
30
|
+
Tooltip,
|
|
31
|
+
{ className: classes.icon, title: title, variant: 'light' },
|
|
32
|
+
children
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Warning.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
37
|
+
title: PropTypes.string,
|
|
38
|
+
children: PropTypes.node
|
|
39
|
+
} : {};
|
|
40
|
+
|
|
41
|
+
var Mode = function Mode(_ref2) {
|
|
42
|
+
var changeMode = _ref2.changeMode,
|
|
43
|
+
mode = _ref2.mode,
|
|
44
|
+
_ref2$modes = _ref2.modes,
|
|
45
|
+
modes = _ref2$modes === undefined ? [] : _ref2$modes,
|
|
46
|
+
children = _ref2.children;
|
|
47
|
+
|
|
48
|
+
var classes = useStyles();
|
|
49
|
+
return React.createElement(
|
|
50
|
+
RadioGroup,
|
|
51
|
+
{ onChange: function onChange(e) {
|
|
52
|
+
return changeMode(e.target.value);
|
|
53
|
+
}, value: mode },
|
|
54
|
+
R.map(function (_ref3) {
|
|
55
|
+
var label = _ref3.label,
|
|
56
|
+
value = _ref3.value,
|
|
57
|
+
popperLabel = _ref3.popperLabel;
|
|
58
|
+
return React.createElement(FormControlLabel, {
|
|
59
|
+
classes: { label: classes.label },
|
|
60
|
+
key: value,
|
|
61
|
+
control: React.createElement(Radio, { variant: 'outlined', color: 'primary' }),
|
|
62
|
+
label: React.createElement(
|
|
63
|
+
'span',
|
|
64
|
+
null,
|
|
65
|
+
label,
|
|
66
|
+
popperLabel && React.createElement(
|
|
67
|
+
Warning,
|
|
68
|
+
{ title: popperLabel },
|
|
69
|
+
children
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
value: value
|
|
73
|
+
});
|
|
74
|
+
})(modes)
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Mode.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
79
|
+
changeMode: PropTypes.func,
|
|
80
|
+
children: PropTypes.node,
|
|
81
|
+
mode: PropTypes.string,
|
|
82
|
+
modes: PropTypes.arrayOf(PropTypes.shape({
|
|
83
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
84
|
+
value: PropTypes.string,
|
|
85
|
+
popperLabel: PropTypes.string
|
|
86
|
+
}))
|
|
87
|
+
} : {};
|
|
88
|
+
|
|
89
|
+
export default Mode;
|
package/es/Mode/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NoData component is a basic placeholder to use when there is nothing to display.
|
|
3
|
+
*
|
|
4
|
+
* @memberOf VISIONS
|
|
5
|
+
* @name Mode
|
|
6
|
+
* @tag component
|
|
7
|
+
* @api public
|
|
8
|
+
* @props
|
|
9
|
+
* Mode.propTypes = {
|
|
10
|
+
* changeMode: PropTypes.func,
|
|
11
|
+
* mode: PropTypes.string,
|
|
12
|
+
* modes: PropTypes.arrayOf(
|
|
13
|
+
* PropTypes.shape({
|
|
14
|
+
* label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
15
|
+
* value: PropTypes.string,
|
|
16
|
+
* popperLabel: PropTypes.string,
|
|
17
|
+
* }),
|
|
18
|
+
* ,
|
|
19
|
+
* }
|
|
20
|
+
* @theme
|
|
21
|
+
* // no custom theme there
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export { default } from './Mode';
|
|
@@ -1,6 +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
5
|
import Grid from '@material-ui/core/Grid';
|
|
5
6
|
import { numeralFormat } from './lib';
|
|
6
7
|
import { Select } from '../';
|
|
@@ -37,10 +38,6 @@ var Period = function Period(_ref) {
|
|
|
37
38
|
var startDate = R.head(period);
|
|
38
39
|
var endDate = R.last(period);
|
|
39
40
|
|
|
40
|
-
var startPeriodAvailableBoundaries = [R.head(availableBoundaries), R.defaultTo(R.last(availableBoundaries), endDate)];
|
|
41
|
-
var endPeriodAvailableBoundaries = [R.defaultTo(R.head(availableBoundaries), startDate), R.last(availableBoundaries)];
|
|
42
|
-
var availableRanges = [getRange(startPeriodAvailableBoundaries, startDate), getRange(endPeriodAvailableBoundaries, endDate)];
|
|
43
|
-
|
|
44
41
|
var startPeriodBoundaries = [R.head(boundaries), R.defaultTo(R.last(boundaries), endDate)];
|
|
45
42
|
var endPeriodBoundaries = [R.defaultTo(R.head(boundaries), startDate), R.last(boundaries)];
|
|
46
43
|
var ranges = [getRange(startPeriodBoundaries, startDate), getRange(endPeriodBoundaries, endDate)];
|
|
@@ -50,6 +47,22 @@ var Period = function Period(_ref) {
|
|
|
50
47
|
var onChangeFrequency = function onChangeFrequency(value) {
|
|
51
48
|
if (R.is(Function, changeFrequency)) return changeFrequency(value);
|
|
52
49
|
};
|
|
50
|
+
var _getIsDisabled = function _getIsDisabled(getter) {
|
|
51
|
+
return function (value, id) {
|
|
52
|
+
var _getDate;
|
|
53
|
+
|
|
54
|
+
var fn = R.prop(getter)({ start: R.head, end: R.last });
|
|
55
|
+
if (!isValidNumber(Number(value)) || R.length(availableBoundaries) !== 2) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
var dateValue = getPeriodValue(fn(destructuringDates));
|
|
59
|
+
var date = getDate(frequency, dateValue, (_getDate = {}, _getDate[id] = Number(value), _getDate), getter === 'end');
|
|
60
|
+
var availableStart = availableBoundaries[0],
|
|
61
|
+
availableEnd = availableBoundaries[1];
|
|
62
|
+
|
|
63
|
+
return dateFns.compareAsc(date, availableStart) === -1 || dateFns.compareDesc(date, availableEnd) === -1;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
53
66
|
var onChangePeriod = function onChangePeriod(getter, id) {
|
|
54
67
|
return function (value) {
|
|
55
68
|
var fn = R.prop(getter)({ start: R.head, end: R.last });
|
|
@@ -98,7 +111,8 @@ var Period = function Period(_ref) {
|
|
|
98
111
|
layout = _ref3.layout,
|
|
99
112
|
label = _ref3.label,
|
|
100
113
|
value = _ref3.value,
|
|
101
|
-
testId = _ref3.testId
|
|
114
|
+
testId = _ref3.testId,
|
|
115
|
+
getIsDisabled = _ref3.getIsDisabled;
|
|
102
116
|
return React.createElement(
|
|
103
117
|
Grid,
|
|
104
118
|
{ key: getter, item: true, xs: 12, 'data-testid': testId },
|
|
@@ -127,8 +141,7 @@ var Period = function Period(_ref) {
|
|
|
127
141
|
R.map(function (row) {
|
|
128
142
|
return R.map(function (_ref4) {
|
|
129
143
|
var id = _ref4.id,
|
|
130
|
-
values = _ref4.values
|
|
131
|
-
availableValues = _ref4.availableValues;
|
|
144
|
+
values = _ref4.values;
|
|
132
145
|
|
|
133
146
|
var selectedValue = R.isNil(R.prop(id)(value)) ? R.head(values) : R.prop(id)(value);
|
|
134
147
|
return React.createElement(
|
|
@@ -149,7 +162,7 @@ var Period = function Period(_ref) {
|
|
|
149
162
|
return {
|
|
150
163
|
id: id,
|
|
151
164
|
value: option,
|
|
152
|
-
disabled:
|
|
165
|
+
disabled: getIsDisabled(option, id),
|
|
153
166
|
label: R.ifElse(R.is(String), R.identity, R.prop(id)(numeralFormat))(option)
|
|
154
167
|
};
|
|
155
168
|
})(values)
|
|
@@ -164,15 +177,17 @@ var Period = function Period(_ref) {
|
|
|
164
177
|
})([{
|
|
165
178
|
getter: 'start',
|
|
166
179
|
testId: 'period-picker-start-period-test-id',
|
|
167
|
-
layout: getLayout(frequency, R.head(ranges)
|
|
180
|
+
layout: getLayout(frequency, R.head(ranges)),
|
|
168
181
|
label: R.prop('start')(labels),
|
|
169
|
-
value: getPeriodValue(R.head(destructuringDates))
|
|
182
|
+
value: getPeriodValue(R.head(destructuringDates)),
|
|
183
|
+
getIsDisabled: _getIsDisabled('start')
|
|
170
184
|
}, {
|
|
171
185
|
getter: 'end',
|
|
172
186
|
testId: 'period-picker-end-period-test-id',
|
|
173
|
-
layout: getLayout(frequency, R.last(ranges), R.last(availableRanges)),
|
|
187
|
+
layout: getLayout(frequency, R.last(ranges), /*R.last(availableRanges)*/[]),
|
|
174
188
|
label: R.prop('end')(labels),
|
|
175
|
-
value: getPeriodValue(R.last(destructuringDates))
|
|
189
|
+
value: getPeriodValue(R.last(destructuringDates)),
|
|
190
|
+
getIsDisabled: _getIsDisabled('end')
|
|
176
191
|
}])
|
|
177
192
|
);
|
|
178
193
|
};
|
|
@@ -22,15 +22,15 @@ export var HOUR = 'hour';
|
|
|
22
22
|
export var MINUTE = 'minute';
|
|
23
23
|
|
|
24
24
|
export var layoutFrequencies = {
|
|
25
|
-
S: [[{ values: YEARS,
|
|
26
|
-
A: [[{ values: YEARS,
|
|
27
|
-
Q: [[{ values: YEARS,
|
|
28
|
-
M: [[{ values: YEARS,
|
|
29
|
-
W: [[{ values: YEARS,
|
|
30
|
-
B: [[{ values: YEARS,
|
|
31
|
-
D: [[{ values: YEARS,
|
|
32
|
-
H: [[{ values: YEARS,
|
|
33
|
-
N: [[{ values: YEARS,
|
|
25
|
+
S: [[{ values: YEARS, id: YEAR }, { values: SEMESTERS, id: SEMESTER }]],
|
|
26
|
+
A: [[{ values: YEARS, id: YEAR }]],
|
|
27
|
+
Q: [[{ values: YEARS, id: YEAR }, { values: QUARTERS, id: QUARTER }]],
|
|
28
|
+
M: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }]],
|
|
29
|
+
W: [[{ values: YEARS, id: YEAR }, { values: WEEKS, id: WEEK }]],
|
|
30
|
+
B: [[{ values: YEARS, id: YEAR }, { values: WEEKS, id: WEEK }]],
|
|
31
|
+
D: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }]],
|
|
32
|
+
H: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }], [{ values: FULL_HOURS, id: FULL_HOUR }]],
|
|
33
|
+
N: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }], [{ values: HOURS, id: HOUR }, { values: MINUTES, id: MINUTE }]]
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export var defaultOutputValues = (_defaultOutputValues = {}, _defaultOutputValues[YEARS] = '----', _defaultOutputValues[SEMESTERS] = '-', _defaultOutputValues[QUARTERS] = '-', _defaultOutputValues[MONTHS] = '--', _defaultOutputValues[WEEKS] = '--', _defaultOutputValues[DAYS] = '--', _defaultOutputValues[FULL_HOURS] = '--:00', _defaultOutputValues[HOURS] = '--', _defaultOutputValues[MINUTES] = '--', _defaultOutputValues);
|
package/es/PeriodPicker/lib.js
CHANGED
|
@@ -133,15 +133,12 @@ export var getFrequencyOptions = function getFrequencyOptions(frequencyoptions,
|
|
|
133
133
|
return options;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
export var getLayout = function getLayout(type, range
|
|
136
|
+
export var getLayout = function getLayout(type, range) {
|
|
137
137
|
var layoutPeriods = R.propOr([], type)(layoutFrequencies);
|
|
138
138
|
var hasYear = R.complement(R.isEmpty)(getRanges(range.years));
|
|
139
139
|
return R.map(R.reduce(function (acc, period) {
|
|
140
|
-
if (hasYear) return R.append(R.evolve({ values: setRange(range)
|
|
141
|
-
return R.append(R.evolve({
|
|
142
|
-
values: R.pipe(R.flip(R.prop)(defaultOutputValues), R.flip(R.append)([])),
|
|
143
|
-
availableValues: R.pipe(R.flip(R.prop)(defaultOutputValues), R.flip(R.append)([]))
|
|
144
|
-
}, period), acc);
|
|
140
|
+
if (hasYear) return R.append(R.evolve({ values: setRange(range) }, period), acc);
|
|
141
|
+
return R.append(R.evolve({ values: R.pipe(R.flip(R.prop)(defaultOutputValues), R.flip(R.append)([])) }, period), acc);
|
|
145
142
|
}, []))(layoutPeriods);
|
|
146
143
|
};
|
|
147
144
|
|
package/es/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as LabelDivider } from './LabelDivider';
|
|
|
24
24
|
export { default as Loading } from './Loading';
|
|
25
25
|
export { default as Logo } from './Logo';
|
|
26
26
|
export { default as NoData } from './NoData';
|
|
27
|
+
export { default as Mode } from './Mode';
|
|
27
28
|
export { default as Pagination } from './Pagination';
|
|
28
29
|
export { default as PeriodPicker } from './PeriodPicker';
|
|
29
30
|
export { spotlightScopeListEngine, reduceChildren } from './utils';
|
package/lib/Mode/Mode.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
|
|
5
|
+
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; };
|
|
6
|
+
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
|
|
9
|
+
var _react2 = _interopRequireDefault(_react);
|
|
10
|
+
|
|
11
|
+
var _propTypes = require('prop-types');
|
|
12
|
+
|
|
13
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
14
|
+
|
|
15
|
+
var _ramda = require('ramda');
|
|
16
|
+
|
|
17
|
+
var R = _interopRequireWildcard(_ramda);
|
|
18
|
+
|
|
19
|
+
var _styles = require('@material-ui/core/styles');
|
|
20
|
+
|
|
21
|
+
var _RadioGroup = require('@material-ui/core/RadioGroup');
|
|
22
|
+
|
|
23
|
+
var _RadioGroup2 = _interopRequireDefault(_RadioGroup);
|
|
24
|
+
|
|
25
|
+
var _FormControlLabel = require('@material-ui/core/FormControlLabel');
|
|
26
|
+
|
|
27
|
+
var _FormControlLabel2 = _interopRequireDefault(_FormControlLabel);
|
|
28
|
+
|
|
29
|
+
var _Radio = require('@material-ui/core/Radio');
|
|
30
|
+
|
|
31
|
+
var _Radio2 = _interopRequireDefault(_Radio);
|
|
32
|
+
|
|
33
|
+
var _ = require('../');
|
|
34
|
+
|
|
35
|
+
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; } }
|
|
36
|
+
|
|
37
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
|
+
|
|
39
|
+
var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
40
|
+
return {
|
|
41
|
+
title: _extends({
|
|
42
|
+
padding: 0
|
|
43
|
+
}, R.pathOr({}, ['mixins', 'share', 'title'], theme)),
|
|
44
|
+
label: theme.typography.body2,
|
|
45
|
+
icon: {
|
|
46
|
+
marginLeft: theme.spacing(0.5)
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var Warning = function Warning(_ref) {
|
|
52
|
+
var title = _ref.title,
|
|
53
|
+
children = _ref.children;
|
|
54
|
+
|
|
55
|
+
var classes = useStyles();
|
|
56
|
+
return _react2.default.createElement(
|
|
57
|
+
_.Tooltip,
|
|
58
|
+
{ className: classes.icon, title: title, variant: 'light' },
|
|
59
|
+
children
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Warning.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
64
|
+
title: _propTypes2.default.string,
|
|
65
|
+
children: _propTypes2.default.node
|
|
66
|
+
} : {};
|
|
67
|
+
|
|
68
|
+
var Mode = function Mode(_ref2) {
|
|
69
|
+
var changeMode = _ref2.changeMode,
|
|
70
|
+
mode = _ref2.mode,
|
|
71
|
+
_ref2$modes = _ref2.modes,
|
|
72
|
+
modes = _ref2$modes === undefined ? [] : _ref2$modes,
|
|
73
|
+
children = _ref2.children;
|
|
74
|
+
|
|
75
|
+
var classes = useStyles();
|
|
76
|
+
return _react2.default.createElement(
|
|
77
|
+
_RadioGroup2.default,
|
|
78
|
+
{ onChange: function onChange(e) {
|
|
79
|
+
return changeMode(e.target.value);
|
|
80
|
+
}, value: mode },
|
|
81
|
+
R.map(function (_ref3) {
|
|
82
|
+
var label = _ref3.label,
|
|
83
|
+
value = _ref3.value,
|
|
84
|
+
popperLabel = _ref3.popperLabel;
|
|
85
|
+
return _react2.default.createElement(_FormControlLabel2.default, {
|
|
86
|
+
classes: { label: classes.label },
|
|
87
|
+
key: value,
|
|
88
|
+
control: _react2.default.createElement(_Radio2.default, { variant: 'outlined', color: 'primary' }),
|
|
89
|
+
label: _react2.default.createElement(
|
|
90
|
+
'span',
|
|
91
|
+
null,
|
|
92
|
+
label,
|
|
93
|
+
popperLabel && _react2.default.createElement(
|
|
94
|
+
Warning,
|
|
95
|
+
{ title: popperLabel },
|
|
96
|
+
children
|
|
97
|
+
)
|
|
98
|
+
),
|
|
99
|
+
value: value
|
|
100
|
+
});
|
|
101
|
+
})(modes)
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
Mode.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
106
|
+
changeMode: _propTypes2.default.func,
|
|
107
|
+
children: _propTypes2.default.node,
|
|
108
|
+
mode: _propTypes2.default.string,
|
|
109
|
+
modes: _propTypes2.default.arrayOf(_propTypes2.default.shape({
|
|
110
|
+
label: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
|
|
111
|
+
value: _propTypes2.default.string,
|
|
112
|
+
popperLabel: _propTypes2.default.string
|
|
113
|
+
}))
|
|
114
|
+
} : {};
|
|
115
|
+
|
|
116
|
+
exports.default = Mode;
|
|
117
|
+
module.exports = exports['default'];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
|
|
5
|
+
var _Mode = require('./Mode');
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, 'default', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _interopRequireDefault(_Mode).default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
module.exports = exports['default'];
|
|
@@ -14,6 +14,10 @@ var _propTypes = require('prop-types');
|
|
|
14
14
|
|
|
15
15
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
16
16
|
|
|
17
|
+
var _dateFns = require('date-fns');
|
|
18
|
+
|
|
19
|
+
var _dateFns2 = _interopRequireDefault(_dateFns);
|
|
20
|
+
|
|
17
21
|
var _Grid = require('@material-ui/core/Grid');
|
|
18
22
|
|
|
19
23
|
var _Grid2 = _interopRequireDefault(_Grid);
|
|
@@ -62,10 +66,6 @@ var Period = function Period(_ref) {
|
|
|
62
66
|
var startDate = R.head(period);
|
|
63
67
|
var endDate = R.last(period);
|
|
64
68
|
|
|
65
|
-
var startPeriodAvailableBoundaries = [R.head(availableBoundaries), R.defaultTo(R.last(availableBoundaries), endDate)];
|
|
66
|
-
var endPeriodAvailableBoundaries = [R.defaultTo(R.head(availableBoundaries), startDate), R.last(availableBoundaries)];
|
|
67
|
-
var availableRanges = [(0, _lib.getRange)(startPeriodAvailableBoundaries, startDate), (0, _lib.getRange)(endPeriodAvailableBoundaries, endDate)];
|
|
68
|
-
|
|
69
69
|
var startPeriodBoundaries = [R.head(boundaries), R.defaultTo(R.last(boundaries), endDate)];
|
|
70
70
|
var endPeriodBoundaries = [R.defaultTo(R.head(boundaries), startDate), R.last(boundaries)];
|
|
71
71
|
var ranges = [(0, _lib.getRange)(startPeriodBoundaries, startDate), (0, _lib.getRange)(endPeriodBoundaries, endDate)];
|
|
@@ -75,6 +75,22 @@ var Period = function Period(_ref) {
|
|
|
75
75
|
var onChangeFrequency = function onChangeFrequency(value) {
|
|
76
76
|
if (R.is(Function, changeFrequency)) return changeFrequency(value);
|
|
77
77
|
};
|
|
78
|
+
var _getIsDisabled = function _getIsDisabled(getter) {
|
|
79
|
+
return function (value, id) {
|
|
80
|
+
var _getDate;
|
|
81
|
+
|
|
82
|
+
var fn = R.prop(getter)({ start: R.head, end: R.last });
|
|
83
|
+
if (!(0, _lib.isValidNumber)(Number(value)) || R.length(availableBoundaries) !== 2) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
var dateValue = (0, _lib.getPeriodValue)(fn(destructuringDates));
|
|
87
|
+
var date = (0, _lib.getDate)(frequency, dateValue, (_getDate = {}, _getDate[id] = Number(value), _getDate), getter === 'end');
|
|
88
|
+
var availableStart = availableBoundaries[0],
|
|
89
|
+
availableEnd = availableBoundaries[1];
|
|
90
|
+
|
|
91
|
+
return _dateFns2.default.compareAsc(date, availableStart) === -1 || _dateFns2.default.compareDesc(date, availableEnd) === -1;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
78
94
|
var onChangePeriod = function onChangePeriod(getter, id) {
|
|
79
95
|
return function (value) {
|
|
80
96
|
var fn = R.prop(getter)({ start: R.head, end: R.last });
|
|
@@ -123,7 +139,8 @@ var Period = function Period(_ref) {
|
|
|
123
139
|
layout = _ref3.layout,
|
|
124
140
|
label = _ref3.label,
|
|
125
141
|
value = _ref3.value,
|
|
126
|
-
testId = _ref3.testId
|
|
142
|
+
testId = _ref3.testId,
|
|
143
|
+
getIsDisabled = _ref3.getIsDisabled;
|
|
127
144
|
return _react2.default.createElement(
|
|
128
145
|
_Grid2.default,
|
|
129
146
|
{ key: getter, item: true, xs: 12, 'data-testid': testId },
|
|
@@ -152,8 +169,7 @@ var Period = function Period(_ref) {
|
|
|
152
169
|
R.map(function (row) {
|
|
153
170
|
return R.map(function (_ref4) {
|
|
154
171
|
var id = _ref4.id,
|
|
155
|
-
values = _ref4.values
|
|
156
|
-
availableValues = _ref4.availableValues;
|
|
172
|
+
values = _ref4.values;
|
|
157
173
|
|
|
158
174
|
var selectedValue = R.isNil(R.prop(id)(value)) ? R.head(values) : R.prop(id)(value);
|
|
159
175
|
return _react2.default.createElement(
|
|
@@ -174,7 +190,7 @@ var Period = function Period(_ref) {
|
|
|
174
190
|
return {
|
|
175
191
|
id: id,
|
|
176
192
|
value: option,
|
|
177
|
-
disabled:
|
|
193
|
+
disabled: getIsDisabled(option, id),
|
|
178
194
|
label: R.ifElse(R.is(String), R.identity, R.prop(id)(_lib.numeralFormat))(option)
|
|
179
195
|
};
|
|
180
196
|
})(values)
|
|
@@ -189,15 +205,17 @@ var Period = function Period(_ref) {
|
|
|
189
205
|
})([{
|
|
190
206
|
getter: 'start',
|
|
191
207
|
testId: 'period-picker-start-period-test-id',
|
|
192
|
-
layout: (0, _lib.getLayout)(frequency, R.head(ranges)
|
|
208
|
+
layout: (0, _lib.getLayout)(frequency, R.head(ranges)),
|
|
193
209
|
label: R.prop('start')(labels),
|
|
194
|
-
value: (0, _lib.getPeriodValue)(R.head(destructuringDates))
|
|
210
|
+
value: (0, _lib.getPeriodValue)(R.head(destructuringDates)),
|
|
211
|
+
getIsDisabled: _getIsDisabled('start')
|
|
195
212
|
}, {
|
|
196
213
|
getter: 'end',
|
|
197
214
|
testId: 'period-picker-end-period-test-id',
|
|
198
|
-
layout: (0, _lib.getLayout)(frequency, R.last(ranges), R.last(availableRanges)),
|
|
215
|
+
layout: (0, _lib.getLayout)(frequency, R.last(ranges), /*R.last(availableRanges)*/[]),
|
|
199
216
|
label: R.prop('end')(labels),
|
|
200
|
-
value: (0, _lib.getPeriodValue)(R.last(destructuringDates))
|
|
217
|
+
value: (0, _lib.getPeriodValue)(R.last(destructuringDates)),
|
|
218
|
+
getIsDisabled: _getIsDisabled('end')
|
|
201
219
|
}])
|
|
202
220
|
);
|
|
203
221
|
};
|
|
@@ -26,15 +26,15 @@ var HOUR = exports.HOUR = 'hour';
|
|
|
26
26
|
var MINUTE = exports.MINUTE = 'minute';
|
|
27
27
|
|
|
28
28
|
var layoutFrequencies = exports.layoutFrequencies = {
|
|
29
|
-
S: [[{ values: YEARS,
|
|
30
|
-
A: [[{ values: YEARS,
|
|
31
|
-
Q: [[{ values: YEARS,
|
|
32
|
-
M: [[{ values: YEARS,
|
|
33
|
-
W: [[{ values: YEARS,
|
|
34
|
-
B: [[{ values: YEARS,
|
|
35
|
-
D: [[{ values: YEARS,
|
|
36
|
-
H: [[{ values: YEARS,
|
|
37
|
-
N: [[{ values: YEARS,
|
|
29
|
+
S: [[{ values: YEARS, id: YEAR }, { values: SEMESTERS, id: SEMESTER }]],
|
|
30
|
+
A: [[{ values: YEARS, id: YEAR }]],
|
|
31
|
+
Q: [[{ values: YEARS, id: YEAR }, { values: QUARTERS, id: QUARTER }]],
|
|
32
|
+
M: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }]],
|
|
33
|
+
W: [[{ values: YEARS, id: YEAR }, { values: WEEKS, id: WEEK }]],
|
|
34
|
+
B: [[{ values: YEARS, id: YEAR }, { values: WEEKS, id: WEEK }]],
|
|
35
|
+
D: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }]],
|
|
36
|
+
H: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }], [{ values: FULL_HOURS, id: FULL_HOUR }]],
|
|
37
|
+
N: [[{ values: YEARS, id: YEAR }, { values: MONTHS, id: MONTH }, { values: DAYS, id: DAY }], [{ values: HOURS, id: HOUR }, { values: MINUTES, id: MINUTE }]]
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
var defaultOutputValues = exports.defaultOutputValues = (_defaultOutputValues = {}, _defaultOutputValues[YEARS] = '----', _defaultOutputValues[SEMESTERS] = '-', _defaultOutputValues[QUARTERS] = '-', _defaultOutputValues[MONTHS] = '--', _defaultOutputValues[WEEKS] = '--', _defaultOutputValues[DAYS] = '--', _defaultOutputValues[FULL_HOURS] = '--:00', _defaultOutputValues[HOURS] = '--', _defaultOutputValues[MINUTES] = '--', _defaultOutputValues);
|
package/lib/PeriodPicker/lib.js
CHANGED
|
@@ -151,15 +151,12 @@ var getFrequencyOptions = exports.getFrequencyOptions = function getFrequencyOpt
|
|
|
151
151
|
return options;
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
var getLayout = exports.getLayout = function getLayout(type, range
|
|
154
|
+
var getLayout = exports.getLayout = function getLayout(type, range) {
|
|
155
155
|
var layoutPeriods = R.propOr([], type)(_constants.layoutFrequencies);
|
|
156
156
|
var hasYear = R.complement(R.isEmpty)(getRanges(range.years));
|
|
157
157
|
return R.map(R.reduce(function (acc, period) {
|
|
158
|
-
if (hasYear) return R.append(R.evolve({ values: setRange(range)
|
|
159
|
-
return R.append(R.evolve({
|
|
160
|
-
values: R.pipe(R.flip(R.prop)(_constants.defaultOutputValues), R.flip(R.append)([])),
|
|
161
|
-
availableValues: R.pipe(R.flip(R.prop)(_constants.defaultOutputValues), R.flip(R.append)([]))
|
|
162
|
-
}, period), acc);
|
|
158
|
+
if (hasYear) return R.append(R.evolve({ values: setRange(range) }, period), acc);
|
|
159
|
+
return R.append(R.evolve({ values: R.pipe(R.flip(R.prop)(_constants.defaultOutputValues), R.flip(R.append)([])) }, period), acc);
|
|
163
160
|
}, []))(layoutPeriods);
|
|
164
161
|
};
|
|
165
162
|
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.T4_BREAKPOINTS = exports.innerPalette = exports.sisccTheme = exports.HierarchicalFilter = exports.AdvancedFilterDialog = exports.VirtualizedTree = exports.AuthDialog = exports.VerticalButton = exports.UserRightForm = exports.Tooltip = exports.ToggleButton = exports.Tag = exports.TablePreview = exports.TableLayout = exports.Cell = exports.TableHtml5 = exports.TableHeader = exports.TableFooter = exports.Spotlight = exports.SisccFooter = exports.Share = exports.Select = exports.ScopeList = exports.reduceChildren = exports.spotlightScopeListEngine = exports.PeriodPicker = exports.Pagination = exports.NoData = exports.Logo = exports.Loading = exports.LabelDivider = exports.InputNumber = exports.Input = exports.ExpansionPanel = exports.DataFooter = exports.DataHeader = exports.Dataflow = exports.DataEdit = exports.Contact = exports.CollapsibleTree = exports.CollapseButtons = exports.GroupedChips = exports.DeleteAllChip = exports.ChartsConfig = exports.Button = exports.Breadcrumbs = exports.ApiQueries = exports.Alert = undefined;
|
|
4
|
+
exports.T4_BREAKPOINTS = exports.innerPalette = exports.sisccTheme = exports.HierarchicalFilter = exports.AdvancedFilterDialog = exports.VirtualizedTree = exports.AuthDialog = exports.VerticalButton = exports.UserRightForm = exports.Tooltip = exports.ToggleButton = exports.Tag = exports.TablePreview = exports.TableLayout = exports.Cell = exports.TableHtml5 = exports.TableHeader = exports.TableFooter = exports.Spotlight = exports.SisccFooter = exports.Share = exports.Select = exports.ScopeList = exports.reduceChildren = exports.spotlightScopeListEngine = exports.PeriodPicker = exports.Pagination = exports.Mode = exports.NoData = exports.Logo = exports.Loading = exports.LabelDivider = exports.InputNumber = exports.Input = exports.ExpansionPanel = exports.DataFooter = exports.DataHeader = exports.Dataflow = exports.DataEdit = exports.Contact = exports.CollapsibleTree = exports.CollapseButtons = exports.GroupedChips = exports.DeleteAllChip = exports.ChartsConfig = exports.Button = exports.Breadcrumbs = exports.ApiQueries = exports.Alert = undefined;
|
|
5
5
|
|
|
6
6
|
var _Alert = require('./Alert');
|
|
7
7
|
|
|
@@ -201,6 +201,15 @@ Object.defineProperty(exports, 'NoData', {
|
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
203
|
|
|
204
|
+
var _Mode = require('./Mode');
|
|
205
|
+
|
|
206
|
+
Object.defineProperty(exports, 'Mode', {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function get() {
|
|
209
|
+
return _interopRequireDefault(_Mode).default;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
204
213
|
var _Pagination = require('./Pagination');
|
|
205
214
|
|
|
206
215
|
Object.defineProperty(exports, 'Pagination', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-visions",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
4
4
|
"description": "Library of visual components",
|
|
5
5
|
"author": "OECD",
|
|
6
6
|
"homepage": "https://visions-qa.siscc.org/#o",
|
|
@@ -206,6 +206,7 @@
|
|
|
206
206
|
]
|
|
207
207
|
},
|
|
208
208
|
"prettier": {
|
|
209
|
+
"endOfLine": "lf",
|
|
209
210
|
"useTabs": false,
|
|
210
211
|
"printWidth": 100,
|
|
211
212
|
"tabWidth": 2,
|