@sis-cc/dotstatsuite-components 13.5.2 → 13.5.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © OECD 2019-2021
3
+ Copyright © OECD 2019-2022
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,9 +9,9 @@ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
9
 
10
10
  var _defineProperty3 = _interopRequireDefault(_defineProperty2);
11
11
 
12
- var _extends3 = require('babel-runtime/helpers/extends');
12
+ var _extends4 = require('babel-runtime/helpers/extends');
13
13
 
14
- var _extends4 = _interopRequireDefault(_extends3);
14
+ var _extends5 = _interopRequireDefault(_extends4);
15
15
 
16
16
  var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
17
17
 
@@ -74,45 +74,42 @@ var refineHeader = exports.refineHeader = function refineHeader(header, extracte
74
74
  };
75
75
 
76
76
  var truncateSectionRows = exports.truncateSectionRows = function truncateSectionRows(n, sectionsData) {
77
- var _R$pipe = R.pipe(R.last, // last section
78
- R.nth(1), // rows
79
- R.splitAt(R.negate(n)) // truncate from the end
80
- )(sectionsData),
81
- _R$pipe2 = (0, _slicedToArray3.default)(_R$pipe, 2),
82
- rest = _R$pipe2[0],
83
- extracted = _R$pipe2[1];
84
-
85
- var truncatedData = R.isEmpty(rest) ? R.dropLast(1, sectionsData) // remove section if no more rows
86
- : R.adjust(-1, R.adjust(1, R.always(rest)), sectionsData);
87
-
88
- var sectionKey = R.join(':', R.pipe(R.last, R.head)(sectionsData) || []);
89
- var rowKeys = R.map(R.join(':'), extracted);
90
-
91
- var extractedLength = R.length(extracted);
92
- if (extractedLength < n) {
93
- var _truncateSectionRows = truncateSectionRows(n - extractedLength, truncatedData),
94
- truncated = _truncateSectionRows.truncated,
95
- extractedKeys = _truncateSectionRows.extractedKeys;
96
-
97
- return { truncated: truncated, extractedKeys: (0, _extends4.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, rowKeys)) };
77
+ var truncated = sectionsData;
78
+ var extractedKeys = {};
79
+ var _n = n;
80
+ while (_n > 0) {
81
+ var lastSection = R.last(truncated);
82
+ var rows = lastSection[1];
83
+ var rowsLength = R.length(rows);
84
+ var sectionKey = R.join(':', R.head(lastSection));
85
+ if (rowsLength > _n) {
86
+ var _R$splitAt = R.splitAt(R.negate(n), rows),
87
+ _R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
88
+ rest = _R$splitAt2[0],
89
+ extracted = _R$splitAt2[1];
90
+
91
+ var updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
92
+ truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
93
+ extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(R.join(':'), extracted)));
94
+ _n = 0;
95
+ } else {
96
+ truncated = R.dropLast(1, truncated);
97
+ extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(R.join(':'), rows)));
98
+ _n = _n - rowsLength;
99
+ }
98
100
  }
99
-
100
- return { truncated: truncatedData, extractedKeys: (0, _defineProperty3.default)({}, sectionKey, rowKeys) };
101
+ return { truncated: truncated, extractedKeys: extractedKeys };
101
102
  };
102
103
 
103
104
  var truncateHeader = exports.truncateHeader = function truncateHeader(n, headerData) {
104
- var _R$splitAt = R.splitAt(R.negate(n))(headerData),
105
- _R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
106
- truncated = _R$splitAt2[0],
107
- extracted = _R$splitAt2[1];
105
+ var _R$splitAt3 = R.splitAt(R.negate(n))(headerData),
106
+ _R$splitAt4 = (0, _slicedToArray3.default)(_R$splitAt3, 2),
107
+ truncated = _R$splitAt4[0],
108
+ extracted = _R$splitAt4[1];
108
109
 
109
110
  return { truncated: truncated, extractedKeys: R.map(R.join(':'), extracted) };
110
111
  };
111
112
 
112
- var refineLength = function refineLength(length) {
113
- return length === 0 ? 1 : length;
114
- };
115
-
116
113
  var truncateLayout = function truncateLayout(isVertical) {
117
114
  return R.ifElse(R.always(isVertical), truncateSectionRows, truncateHeader);
118
115
  };
@@ -16,7 +16,9 @@ var getMetadataCoordinates = exports.getMetadataCoordinates = function getMetada
16
16
  var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
17
17
  var metadataAvailKeys = R.pipe(R.pathOr([], ['data', 'dataSets', 0, 'dimensionGroupAttributes']), R.map(function (indexes) {
18
18
  return R.props(indexes, annotations);
19
- }), R.filter(R.find(R.propEq('type', 'HAS_METADATA'))), R.keys)(sdmxJson);
19
+ }), R.filter(R.find(function (a) {
20
+ return a && R.propEq('type', 'HAS_METADATA', a);
21
+ })), R.keys)(sdmxJson);
20
22
 
21
23
  return R.map(function (key) {
22
24
  var indexes = R.split(':', key);
@@ -87,12 +87,12 @@ var Chart = function Chart(_ref) {
87
87
  return _react2.default.createElement(
88
88
  'div',
89
89
  { className: (0, _classnames2.default)((0, _defineProperty3.default)({}, classes.chartContainer, !R.equals(_constants.SCATTER, type))) },
90
+ R.is(Number, width) && width < 370 ? null : _react2.default.createElement(_AxisLegend2.default, { axis: 'y', data: { series: series }, type: type }),
90
91
  _react2.default.createElement(ChartClass, {
91
92
  data: series,
92
93
  options: options,
93
94
  getAxisOptions: getAxisOptions
94
- }),
95
- R.is(Number, width) && width < 370 ? null : _react2.default.createElement(_AxisLegend2.default, { axis: 'y', data: { series: series }, type: type })
95
+ })
96
96
  );
97
97
  };
98
98
 
@@ -37,7 +37,7 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
37
37
  yLegend: (0, _extends3.default)({}, legendFont, {
38
38
  left: 10,
39
39
  position: 'absolute',
40
- top: 10
40
+ zIndex: 1
41
41
  })
42
42
  };
43
43
  });
@@ -51,8 +51,8 @@ var AxisLegend = function AxisLegend(_ref) {
51
51
  data = _ref.data,
52
52
  type = _ref.type;
53
53
 
54
- if (!R.equals(_constants.SCATTER, type)) return null;
55
54
  var classes = useStyles();
55
+ if (!R.equals(_constants.SCATTER, type)) return null;
56
56
  switch (axis) {
57
57
  case 'x':
58
58
  return _react2.default.createElement(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-components",
3
3
  "description": "Set components based on React.",
4
- "version": "13.5.2",
4
+ "version": "13.5.5",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -79,29 +79,28 @@ export const refineHeader = (header, extractedKeys, curatedObs) => R.filter( //
79
79
  )(header);
80
80
 
81
81
  export const truncateSectionRows = (n, sectionsData) => {
82
- const [rest, extracted] = R.pipe(
83
- R.last, // last section
84
- R.nth(1), // rows
85
- R.splitAt(R.negate(n)) // truncate from the end
86
- )(sectionsData);
87
-
88
- const truncatedData = R.isEmpty(rest)
89
- ? R.dropLast(1, sectionsData) // remove section if no more rows
90
- : R.adjust(-1, R.adjust(1, R.always(rest)), sectionsData)
91
-
92
- const sectionKey = R.join(':', R.pipe(R.last, R.head)(sectionsData) || []);
93
- const rowKeys = R.map(R.join(':'), extracted);
94
-
95
- const extractedLength = R.length(extracted);
96
- if (extractedLength < n) {
97
- const { truncated, extractedKeys } = truncateSectionRows(
98
- n - extractedLength,
99
- truncatedData
100
- );
101
- return ({ truncated, extractedKeys: { ...extractedKeys, [sectionKey]: rowKeys } });
82
+ let truncated = sectionsData;
83
+ let extractedKeys = {};
84
+ let _n = n;
85
+ while (_n > 0) {
86
+ const lastSection = R.last(truncated);
87
+ const rows = lastSection[1];
88
+ const rowsLength = R.length(rows);
89
+ const sectionKey = R.join(':', R.head(lastSection));
90
+ if (rowsLength > _n) {
91
+ const [rest, extracted] = R.splitAt(R.negate(n), rows);
92
+ const updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
93
+ truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
94
+ extractedKeys = { ...extractedKeys, [sectionKey]: R.map(R.join(':'), extracted) };
95
+ _n = 0;
96
+ }
97
+ else {
98
+ truncated = R.dropLast(1, truncated);
99
+ extractedKeys = { ...extractedKeys, [sectionKey]: R.map(R.join(':'), rows) };
100
+ _n = _n - rowsLength;
101
+ }
102
102
  }
103
-
104
- return ({ truncated: truncatedData, extractedKeys: { [sectionKey]: rowKeys } });
103
+ return ({ truncated, extractedKeys });
105
104
  };
106
105
 
107
106
  export const truncateHeader = (n, headerData) => {
@@ -109,8 +108,6 @@ export const truncateHeader = (n, headerData) => {
109
108
  return ({ truncated, extractedKeys: R.map(R.join(':'), extracted) });
110
109
  };
111
110
 
112
- const refineLength = length => length === 0 ? 1 : length;
113
-
114
111
  const truncateLayout = (isVertical) => R.ifElse(
115
112
  R.always(isVertical),
116
113
  truncateSectionRows,
@@ -6,7 +6,7 @@ export const getMetadataCoordinates = (sdmxJson) => {
6
6
  const metadataAvailKeys = R.pipe(
7
7
  R.pathOr([], ['data', 'dataSets', 0, 'dimensionGroupAttributes']),
8
8
  R.map(indexes => R.props(indexes, annotations)),
9
- R.filter(R.find(R.propEq('type', 'HAS_METADATA'))),
9
+ R.filter(R.find(a => a && R.propEq('type', 'HAS_METADATA', a))),
10
10
  R.keys
11
11
  )(sdmxJson);
12
12
 
@@ -42,16 +42,16 @@ const Chart = ({ options, series, type, width, getAxisOptions }) => {
42
42
  const ChartClass = charts[type];
43
43
  return (
44
44
  <div className={cx({ [classes.chartContainer]: !R.equals(SCATTER, type) })}>
45
- <ChartClass
46
- data={series}
47
- options={options}
48
- getAxisOptions={getAxisOptions}
49
- />
50
45
  {
51
46
  (R.is(Number, width) && width < 370)
52
47
  ? null
53
48
  : <AxisLegend axis="y" data={{ series }} type={type} />
54
49
  }
50
+ <ChartClass
51
+ data={series}
52
+ options={options}
53
+ getAxisOptions={getAxisOptions}
54
+ />
55
55
  </div>
56
56
  );
57
57
  };
@@ -13,7 +13,7 @@ const useStyles = makeStyles(theme => {
13
13
  ...legendFont,
14
14
  left: 10,
15
15
  position: 'absolute',
16
- top: 10,
16
+ zIndex: 1,
17
17
  }
18
18
  })
19
19
  });
@@ -26,9 +26,9 @@ const getAxisLabel = axis => R.pipe(
26
26
  );
27
27
 
28
28
  const AxisLegend = ({ axis, data, type }) => {
29
+ const classes = useStyles();
29
30
  if (!R.equals(SCATTER, type))
30
31
  return null;
31
- const classes = useStyles();
32
32
  switch (axis) {
33
33
  case 'x':
34
34
  return <span className={classes.xLegend}>→ {getAxisLabel('x')(data)}</span>;
@@ -7,26 +7,26 @@ describe('getMSDInformations tests', () => {
7
7
  const expected = {
8
8
  attributes: {
9
9
  STRING_TYPE: { format: 'String', parent: '#ROOT', id: 'STRING_TYPE', name: 'STRING_TYPE en' },
10
- STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT', id: 'STRING_MULTILANG_TYPE', name: [undefined] },
11
- ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_TYPE', name: [undefined] },
12
- ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_MULTILANG_TYPE', name: [undefined] },
13
- BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT', id: 'BOOLEAN_TYPE', name: [undefined] },
14
- XHTML_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_TYPE', name: [undefined] },
15
- XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_MULTILANG_TYPE', name: [undefined] },
16
- INTEGER_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_TYPE', name: [undefined] },
17
- INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_MULTILANG_TYPE', name: [undefined] },
18
- DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_TYPE', name: [undefined] },
19
- DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_MULTILANG_TYPE', name: [undefined] },
20
- DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT', id: 'DATETIME_TYPE', name: [undefined] },
21
- TIME_TYPE: { format: 'Time', parent: '#ROOT', id: 'TIME_TYPE', name: [undefined] },
22
- GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT', id: 'GREGORIANDAY_TYPE', name: [undefined] },
23
- GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT', id: 'GREGORIAN_YEAR_TYPE', name: [undefined] },
24
- GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT', id: 'GREGORIAN_YEARMONTH_TYPE', name: [undefined] },
25
- CONTACT: { format: 'String', parent: '#ROOT', id: 'CONTACT', name: [undefined] },
26
- 'CONTACT.CONTACT_NAME': { format: 'String', parent: 'CONTACT', id: 'CONTACT_NAME', name: [undefined] },
27
- 'CONTACT.CONTACT_EMAIL': { format: 'String', parent: 'CONTACT', id: 'CONTACT_EMAIL', name: [undefined] },
28
- 'CONTACT.CONTACT_PHONE': { format: 'Numeric', parent: 'CONTACT', id: 'CONTACT_PHONE', name: [undefined] },
29
- 'CONTACT.CONTACT_ORGANISATION': { format: 'String', parent: 'CONTACT', id: 'CONTACT_ORGANISATION', name: [undefined] }
10
+ STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT', id: 'STRING_MULTILANG_TYPE', name: undefined },
11
+ ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_TYPE', name: undefined },
12
+ ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_MULTILANG_TYPE', name: undefined },
13
+ BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT', id: 'BOOLEAN_TYPE', name: undefined },
14
+ XHTML_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_TYPE', name: undefined },
15
+ XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_MULTILANG_TYPE', name: undefined },
16
+ INTEGER_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_TYPE', name: undefined },
17
+ INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_MULTILANG_TYPE', name: undefined },
18
+ DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_TYPE', name: undefined },
19
+ DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_MULTILANG_TYPE', name: undefined },
20
+ DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT', id: 'DATETIME_TYPE', name: undefined },
21
+ TIME_TYPE: { format: 'Time', parent: '#ROOT', id: 'TIME_TYPE', name: undefined },
22
+ GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT', id: 'GREGORIANDAY_TYPE', name: undefined },
23
+ GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT', id: 'GREGORIAN_YEAR_TYPE', name: undefined },
24
+ GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT', id: 'GREGORIAN_YEARMONTH_TYPE', name: undefined },
25
+ CONTACT: { format: 'String', parent: '#ROOT', id: 'CONTACT', name: undefined },
26
+ 'CONTACT.CONTACT_NAME': { format: 'String', parent: 'CONTACT', id: 'CONTACT_NAME', name: undefined },
27
+ 'CONTACT.CONTACT_EMAIL': { format: 'String', parent: 'CONTACT', id: 'CONTACT_EMAIL', name: undefined },
28
+ 'CONTACT.CONTACT_PHONE': { format: 'Numeric', parent: 'CONTACT', id: 'CONTACT_PHONE', name: undefined },
29
+ 'CONTACT.CONTACT_ORGANISATION': { format: 'String', parent: 'CONTACT', id: 'CONTACT_ORGANISATION', name: undefined }
30
30
  }
31
31
  };
32
32