@sis-cc/dotstatsuite-components 13.5.4 → 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
  };
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.4",
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,
@@ -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