@sis-cc/dotstatsuite-visions 7.10.0 → 7.11.1

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.
@@ -6,6 +6,7 @@ import React, { useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import * as R from 'ramda';
8
8
  import cx from 'classnames';
9
+ import useSize from '@react-hook/size';
9
10
  import { makeStyles } from '@material-ui/core/styles';
10
11
  import Typography from '@material-ui/core/Typography';
11
12
  import Collapse from '@material-ui/core/Collapse';
@@ -86,20 +87,17 @@ var useStyles = makeStyles(function (theme) {
86
87
  margin: theme.spacing(0.5, 0.5)
87
88
  },
88
89
  fadeContent: {
89
- maxHeight: 70,
90
90
  color: theme.palette.grey['A200'],
91
91
  position: 'relative',
92
92
  overflow: 'hidden'
93
93
  },
94
94
  fading: {
95
95
  position: 'absolute',
96
- bottom: 0,
97
96
  left: 0,
98
- width: '100%',
97
+ right: 0,
99
98
  height: 15,
100
- textAlign: 'center',
101
99
  margin: 0,
102
- padding: theme.spacing(0, 0.5, 0.5, 0.5),
100
+ padding: 0,
103
101
  backgroundImage: 'linear-gradient(to bottom, transparent, white)'
104
102
  },
105
103
  wrapper: {
@@ -161,6 +159,20 @@ var Dataflow = function Dataflow(_ref2) {
161
159
 
162
160
  var description = R.propOr('', 'description', body);
163
161
 
162
+ var target = React.useRef();
163
+
164
+ var _useSize = useSize(target),
165
+ height = _useSize[1];
166
+
167
+ var handleExpand = function handleExpand() {
168
+ setExpand(function (prev) {
169
+ return !prev;
170
+ });
171
+ };
172
+
173
+ //const collapsedSize = R.min(!isExpanded ? height : !collapsedSize ? height : collapsedSize, 70);
174
+ var collapsedSize = R.min(height, 70);
175
+
164
176
  return React.createElement(
165
177
  Card,
166
178
  { elevation: 0, square: true, className: classes.card, 'data-testid': '' + testId },
@@ -196,12 +208,13 @@ var Dataflow = function Dataflow(_ref2) {
196
208
  Collapse,
197
209
  {
198
210
  'in': isExpanded,
199
- collapsedSize: 70,
211
+ collapsedSize: collapsedSize,
200
212
  classes: isExpanded ? undefined : { wrapper: classes.wrapper }
201
213
  },
202
214
  React.createElement(
203
215
  CardContent,
204
216
  {
217
+ ref: target,
205
218
  className: cx(classes.cardContent, (_cx = {}, _cx[classes.fadeContent] = !isExpanded, _cx))
206
219
  },
207
220
  React.createElement(
@@ -213,7 +226,7 @@ var Dataflow = function Dataflow(_ref2) {
213
226
  },
214
227
  React.createElement(HTMLRenderer, { html: description })
215
228
  ),
216
- !isExpanded && React.createElement('div', { className: classes.fading })
229
+ !isExpanded && React.createElement('div', { className: classes.fading, style: { top: collapsedSize - 15 } })
217
230
  )
218
231
  ),
219
232
  R.not(R.empty(R.propOr('', 'highlightDescription')(body))) && React.createElement(
@@ -346,9 +359,7 @@ var Dataflow = function Dataflow(_ref2) {
346
359
  'data-testid': 'dataflow-expand-button-test-id',
347
360
  'aria-label': 'expand',
348
361
  onClick: function onClick() {
349
- return setExpand(function (prev) {
350
- return !prev;
351
- });
362
+ return handleExpand();
352
363
  },
353
364
  color: 'primary',
354
365
  size: 'small'
@@ -1,6 +1,4 @@
1
1
  /**
2
- * Dataflow
3
- *
4
2
  * Without onDownload the button download will disappear
5
3
  *
6
4
  * @demoReady
@@ -54,7 +54,8 @@ var Item = function Item(_ref) {
54
54
  accessibility = _ref.accessibility,
55
55
  index = _ref.index,
56
56
  labelRenderer = _ref.labelRenderer,
57
- HTMLRenderer = _ref.HTMLRenderer;
57
+ HTMLRenderer = _ref.HTMLRenderer,
58
+ hierarchicalId = _ref.hierarchicalId;
58
59
 
59
60
  var _React$useState = React.useState(false),
60
61
  isTooltipShown = _React$useState[0],
@@ -171,7 +172,7 @@ var Item = function Item(_ref) {
171
172
  className: classes.containerArrow,
172
173
  tabIndex: 0,
173
174
  onClick: function onClick() {
174
- return changeList(id);
175
+ return changeList(hierarchicalId || id);
175
176
  },
176
177
  onKeyPress: function onKeyPress(e) {
177
178
  if (e.key === 'Enter') {
@@ -232,7 +233,8 @@ Item.propTypes = process.env.NODE_ENV !== "production" ? {
232
233
  accessibility: PropTypes.bool,
233
234
  index: PropTypes.number,
234
235
  labelRenderer: PropTypes.func,
235
- HTMLRenderer: PropTypes.func
236
+ HTMLRenderer: PropTypes.func,
237
+ hierarchicalId: PropTypes.string
236
238
  } : {};
237
239
 
238
240
  export default Item;
@@ -85,7 +85,7 @@ export var getPlaceholder = function getPlaceholder(_ref2) {
85
85
  //----------------------------------------------------------------------------------------------List
86
86
  export var withHasChild = function withHasChild(itemsByParentId) {
87
87
  return function (item) {
88
- return R.assoc('hasChild', R.pipe(R.prop(item.id), R.isNil, R.not)(itemsByParentId))(item);
88
+ return R.assoc('hasChild', R.pipe(R.prop(item.hierarchicalId || item.id), R.isNil, R.not)(itemsByParentId))(item);
89
89
  };
90
90
  };
91
91
  export var getCurrentList = function getCurrentList(_ref3) {
@@ -110,7 +110,7 @@ export var getList = function getList(_ref4) {
110
110
  hasPath = _ref4.hasPath,
111
111
  displayAccessor = _ref4.displayAccessor;
112
112
 
113
- var currentItemId = currentItem ? R.prop('id')(currentItem) : null;
113
+ var currentItemId = currentItem ? currentItem.hierarchicalId || currentItem.id : null;
114
114
  if (R.or(R.isEmpty(term), R.isNil(R.prop('defaultSpotlight')(topElementProps)))) {
115
115
  var itemsByParentIdDisplayed = getItemsIndexedByParentId(displayAccessor)(items);
116
116
  if (R.isNil(currentItemId)) return R.pipe(getMainList, R.map(function (item) {
@@ -270,7 +270,7 @@ export var withScopeList = function withScopeList(Component) {
270
270
  isMousePreSelection: false,
271
271
  applyToShiftSelected: R.identity
272
272
  }, _this.changeList = function (id) {
273
- return _this.setState({ currentItem: R.prop(id)(_this.state.itemsById), term: '' });
273
+ return _this.setState({ currentItem: R.prop(id)(_this.state.itemsByHierarchicalId), term: '' });
274
274
  }, _this.changeSelection = function (panelId) {
275
275
  return function (id) {
276
276
  return function (event) {
@@ -416,6 +416,7 @@ export var withScopeList = function withScopeList(Component) {
416
416
  term = _this$state.term,
417
417
  itemsByParentId = _this$state.itemsByParentId,
418
418
  itemsById = _this$state.itemsById,
419
+ itemsByHierarchicalId = _this$state.itemsByHierarchicalId,
419
420
  shiftSelection = _this$state.shiftSelection,
420
421
  ctrlSelection = _this$state.ctrlSelection,
421
422
  mouseSelection = _this$state.mouseSelection,
@@ -426,6 +427,7 @@ export var withScopeList = function withScopeList(Component) {
426
427
  items: items,
427
428
  itemsByParentId: itemsByParentId,
428
429
  itemsById: itemsById,
430
+ itemsByHierarchicalId: itemsByHierarchicalId,
429
431
  topElementProps: topElementProps,
430
432
  currentItem: currentItem,
431
433
  term: term,
@@ -445,7 +447,7 @@ export var withScopeList = function withScopeList(Component) {
445
447
  isActivePanel: isActivePanel,
446
448
  currentItem: currentItem,
447
449
  items: items,
448
- itemsById: itemsById,
450
+ itemsById: itemsByHierarchicalId,
449
451
  hasPath: hasPath
450
452
  }),
451
453
  action: _this.changeSpotlight,
@@ -480,6 +482,9 @@ export var withScopeList = function withScopeList(Component) {
480
482
  }(React.Component), _class.getDerivedStateFromProps = function (props, state) {
481
483
  return _extends({}, state, {
482
484
  itemsById: R.indexBy(R.prop('id'), props.items),
485
+ itemsByHierarchicalId: R.indexBy(function (item) {
486
+ return item.hierarchicalId || item.id;
487
+ }, props.items),
483
488
  itemsByParentId: getItemsIndexedByParentId(props.displayAccessor)(props.items) // only use for hasChild, same keys are overide
484
489
  });
485
490
  }, _temp2;
@@ -94,21 +94,21 @@ var Section = function Section(_ref) {
94
94
  SideIcon: SideIcon,
95
95
  HTMLRenderer: HTMLRenderer
96
96
  }),
97
- R.map(function (sectionbody) {
97
+ R.addIndex(R.map)(function (sectionbody, rowIndex) {
98
98
  var _cx2;
99
99
 
100
- var rowId = sectionbody.key + '_' + sectionIndex;
100
+ var rowId = sectionbody.key + '_' + sectionIndex + '_' + rowIndex;
101
101
  var rowIds = R.pipe(R.map(function (index) {
102
102
  return sectionbody.key + '_' + sectionIndex + '_' + index;
103
103
  }), R.join(' '))(R.times(R.identity, R.length(R.prop('data', sectionbody))));
104
104
  return React.createElement(
105
105
  TableRow,
106
- { key: sectionbody.key },
106
+ { key: rowId },
107
107
  mapIndexed(function (cell, index) {
108
108
  var _cx;
109
109
 
110
110
  var flags = R.path(['value', 'flags'], cell);
111
- var id = rowId + '_' + index;
111
+ var id = rowIndex + '_' + rowId + '_' + index;
112
112
 
113
113
  // special space is used for hierarchy U+2007    
114
114
  var hierarchySpace = R.pipe(R.pathOr([], ['value', 'parents']), R.when(R.isNil, R.always([])), R.length,
@@ -165,9 +165,8 @@ var Section = function Section(_ref) {
165
165
 
166
166
  var intersectionCellId = rowId + '/' + columnIndex;
167
167
  var isActive = R.pipe(R.propOr({}, 'intersectionCellId'), R.equals(intersectionCellId))(activeCellIds);
168
- return React.createElement(Cell, _extends({
169
- key: intersectionCellId
170
- }, R.pathOr({ value: '..' }, [item.key, currentSection, sectionbody.key, 0], cells), {
168
+ return React.createElement(Cell, _extends({}, R.pathOr({ value: '..' }, [item.key, currentSection, sectionbody.key, 0], cells), {
169
+ key: intersectionCellId,
171
170
  headers: rowIds + ' ' + columnIds + ' ' + currentSection,
172
171
  cellHandler: cellHandler,
173
172
  HTMLRenderer: HTMLRenderer,
@@ -20,6 +20,10 @@ var _classnames = require('classnames');
20
20
 
21
21
  var _classnames2 = _interopRequireDefault(_classnames);
22
22
 
23
+ var _size = require('@react-hook/size');
24
+
25
+ var _size2 = _interopRequireDefault(_size);
26
+
23
27
  var _styles = require('@material-ui/core/styles');
24
28
 
25
29
  var _Typography = require('@material-ui/core/Typography');
@@ -140,20 +144,17 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
140
144
  margin: theme.spacing(0.5, 0.5)
141
145
  },
142
146
  fadeContent: {
143
- maxHeight: 70,
144
147
  color: theme.palette.grey['A200'],
145
148
  position: 'relative',
146
149
  overflow: 'hidden'
147
150
  },
148
151
  fading: {
149
152
  position: 'absolute',
150
- bottom: 0,
151
153
  left: 0,
152
- width: '100%',
154
+ right: 0,
153
155
  height: 15,
154
- textAlign: 'center',
155
156
  margin: 0,
156
- padding: theme.spacing(0, 0.5, 0.5, 0.5),
157
+ padding: 0,
157
158
  backgroundImage: 'linear-gradient(to bottom, transparent, white)'
158
159
  },
159
160
  wrapper: {
@@ -215,6 +216,20 @@ var Dataflow = function Dataflow(_ref2) {
215
216
 
216
217
  var description = R.propOr('', 'description', body);
217
218
 
219
+ var target = _react2.default.useRef();
220
+
221
+ var _useSize = (0, _size2.default)(target),
222
+ height = _useSize[1];
223
+
224
+ var handleExpand = function handleExpand() {
225
+ setExpand(function (prev) {
226
+ return !prev;
227
+ });
228
+ };
229
+
230
+ //const collapsedSize = R.min(!isExpanded ? height : !collapsedSize ? height : collapsedSize, 70);
231
+ var collapsedSize = R.min(height, 70);
232
+
218
233
  return _react2.default.createElement(
219
234
  _Card2.default,
220
235
  { elevation: 0, square: true, className: classes.card, 'data-testid': '' + testId },
@@ -250,12 +265,13 @@ var Dataflow = function Dataflow(_ref2) {
250
265
  _Collapse2.default,
251
266
  {
252
267
  'in': isExpanded,
253
- collapsedSize: 70,
268
+ collapsedSize: collapsedSize,
254
269
  classes: isExpanded ? undefined : { wrapper: classes.wrapper }
255
270
  },
256
271
  _react2.default.createElement(
257
272
  _CardContent2.default,
258
273
  {
274
+ ref: target,
259
275
  className: (0, _classnames2.default)(classes.cardContent, (_cx = {}, _cx[classes.fadeContent] = !isExpanded, _cx))
260
276
  },
261
277
  _react2.default.createElement(
@@ -267,7 +283,7 @@ var Dataflow = function Dataflow(_ref2) {
267
283
  },
268
284
  _react2.default.createElement(HTMLRenderer, { html: description })
269
285
  ),
270
- !isExpanded && _react2.default.createElement('div', { className: classes.fading })
286
+ !isExpanded && _react2.default.createElement('div', { className: classes.fading, style: { top: collapsedSize - 15 } })
271
287
  )
272
288
  ),
273
289
  R.not(R.empty(R.propOr('', 'highlightDescription')(body))) && _react2.default.createElement(
@@ -400,9 +416,7 @@ var Dataflow = function Dataflow(_ref2) {
400
416
  'data-testid': 'dataflow-expand-button-test-id',
401
417
  'aria-label': 'expand',
402
418
  onClick: function onClick() {
403
- return setExpand(function (prev) {
404
- return !prev;
405
- });
419
+ return handleExpand();
406
420
  },
407
421
  color: 'primary',
408
422
  size: 'small'
@@ -92,7 +92,8 @@ var Item = function Item(_ref) {
92
92
  accessibility = _ref.accessibility,
93
93
  index = _ref.index,
94
94
  labelRenderer = _ref.labelRenderer,
95
- HTMLRenderer = _ref.HTMLRenderer;
95
+ HTMLRenderer = _ref.HTMLRenderer,
96
+ hierarchicalId = _ref.hierarchicalId;
96
97
 
97
98
  var _React$useState = _react2.default.useState(false),
98
99
  isTooltipShown = _React$useState[0],
@@ -209,7 +210,7 @@ var Item = function Item(_ref) {
209
210
  className: classes.containerArrow,
210
211
  tabIndex: 0,
211
212
  onClick: function onClick() {
212
- return changeList(id);
213
+ return changeList(hierarchicalId || id);
213
214
  },
214
215
  onKeyPress: function onKeyPress(e) {
215
216
  if (e.key === 'Enter') {
@@ -270,7 +271,8 @@ Item.propTypes = process.env.NODE_ENV !== "production" ? {
270
271
  accessibility: _propTypes2.default.bool,
271
272
  index: _propTypes2.default.number,
272
273
  labelRenderer: _propTypes2.default.func,
273
- HTMLRenderer: _propTypes2.default.func
274
+ HTMLRenderer: _propTypes2.default.func,
275
+ hierarchicalId: _propTypes2.default.string
274
276
  } : {};
275
277
 
276
278
  exports.default = Item;
@@ -100,7 +100,7 @@ var getPlaceholder = exports.getPlaceholder = function getPlaceholder(_ref2) {
100
100
  //----------------------------------------------------------------------------------------------List
101
101
  var withHasChild = exports.withHasChild = function withHasChild(itemsByParentId) {
102
102
  return function (item) {
103
- return R.assoc('hasChild', R.pipe(R.prop(item.id), R.isNil, R.not)(itemsByParentId))(item);
103
+ return R.assoc('hasChild', R.pipe(R.prop(item.hierarchicalId || item.id), R.isNil, R.not)(itemsByParentId))(item);
104
104
  };
105
105
  };
106
106
  var getCurrentList = exports.getCurrentList = function getCurrentList(_ref3) {
@@ -125,7 +125,7 @@ var getList = exports.getList = function getList(_ref4) {
125
125
  hasPath = _ref4.hasPath,
126
126
  displayAccessor = _ref4.displayAccessor;
127
127
 
128
- var currentItemId = currentItem ? R.prop('id')(currentItem) : null;
128
+ var currentItemId = currentItem ? currentItem.hierarchicalId || currentItem.id : null;
129
129
  if (R.or(R.isEmpty(term), R.isNil(R.prop('defaultSpotlight')(topElementProps)))) {
130
130
  var itemsByParentIdDisplayed = getItemsIndexedByParentId(displayAccessor)(items);
131
131
  if (R.isNil(currentItemId)) return R.pipe(getMainList, R.map(function (item) {
@@ -285,7 +285,7 @@ var withScopeList = exports.withScopeList = function withScopeList(Component) {
285
285
  isMousePreSelection: false,
286
286
  applyToShiftSelected: R.identity
287
287
  }, _this.changeList = function (id) {
288
- return _this.setState({ currentItem: R.prop(id)(_this.state.itemsById), term: '' });
288
+ return _this.setState({ currentItem: R.prop(id)(_this.state.itemsByHierarchicalId), term: '' });
289
289
  }, _this.changeSelection = function (panelId) {
290
290
  return function (id) {
291
291
  return function (event) {
@@ -431,6 +431,7 @@ var withScopeList = exports.withScopeList = function withScopeList(Component) {
431
431
  term = _this$state.term,
432
432
  itemsByParentId = _this$state.itemsByParentId,
433
433
  itemsById = _this$state.itemsById,
434
+ itemsByHierarchicalId = _this$state.itemsByHierarchicalId,
434
435
  shiftSelection = _this$state.shiftSelection,
435
436
  ctrlSelection = _this$state.ctrlSelection,
436
437
  mouseSelection = _this$state.mouseSelection,
@@ -441,6 +442,7 @@ var withScopeList = exports.withScopeList = function withScopeList(Component) {
441
442
  items: items,
442
443
  itemsByParentId: itemsByParentId,
443
444
  itemsById: itemsById,
445
+ itemsByHierarchicalId: itemsByHierarchicalId,
444
446
  topElementProps: topElementProps,
445
447
  currentItem: currentItem,
446
448
  term: term,
@@ -460,7 +462,7 @@ var withScopeList = exports.withScopeList = function withScopeList(Component) {
460
462
  isActivePanel: isActivePanel,
461
463
  currentItem: currentItem,
462
464
  items: items,
463
- itemsById: itemsById,
465
+ itemsById: itemsByHierarchicalId,
464
466
  hasPath: hasPath
465
467
  }),
466
468
  action: _this.changeSpotlight,
@@ -495,6 +497,9 @@ var withScopeList = exports.withScopeList = function withScopeList(Component) {
495
497
  }(_react2.default.Component), _class.getDerivedStateFromProps = function (props, state) {
496
498
  return _extends({}, state, {
497
499
  itemsById: R.indexBy(R.prop('id'), props.items),
500
+ itemsByHierarchicalId: R.indexBy(function (item) {
501
+ return item.hierarchicalId || item.id;
502
+ }, props.items),
498
503
  itemsByParentId: getItemsIndexedByParentId(props.displayAccessor)(props.items) // only use for hasChild, same keys are overide
499
504
  });
500
505
  }, _temp2;
@@ -136,21 +136,21 @@ var Section = function Section(_ref) {
136
136
  SideIcon: SideIcon,
137
137
  HTMLRenderer: HTMLRenderer
138
138
  }),
139
- R.map(function (sectionbody) {
139
+ R.addIndex(R.map)(function (sectionbody, rowIndex) {
140
140
  var _cx2;
141
141
 
142
- var rowId = sectionbody.key + '_' + sectionIndex;
142
+ var rowId = sectionbody.key + '_' + sectionIndex + '_' + rowIndex;
143
143
  var rowIds = R.pipe(R.map(function (index) {
144
144
  return sectionbody.key + '_' + sectionIndex + '_' + index;
145
145
  }), R.join(' '))(R.times(R.identity, R.length(R.prop('data', sectionbody))));
146
146
  return _react2.default.createElement(
147
147
  _TableRow2.default,
148
- { key: sectionbody.key },
148
+ { key: rowId },
149
149
  mapIndexed(function (cell, index) {
150
150
  var _cx;
151
151
 
152
152
  var flags = R.path(['value', 'flags'], cell);
153
- var id = rowId + '_' + index;
153
+ var id = rowIndex + '_' + rowId + '_' + index;
154
154
 
155
155
  // special space is used for hierarchy U+2007    
156
156
  var hierarchySpace = R.pipe(R.pathOr([], ['value', 'parents']), R.when(R.isNil, R.always([])), R.length,
@@ -207,9 +207,8 @@ var Section = function Section(_ref) {
207
207
 
208
208
  var intersectionCellId = rowId + '/' + columnIndex;
209
209
  var isActive = R.pipe(R.propOr({}, 'intersectionCellId'), R.equals(intersectionCellId))(activeCellIds);
210
- return _react2.default.createElement(_cell2.default, _extends({
211
- key: intersectionCellId
212
- }, R.pathOr({ value: '..' }, [item.key, currentSection, sectionbody.key, 0], cells), {
210
+ return _react2.default.createElement(_cell2.default, _extends({}, R.pathOr({ value: '..' }, [item.key, currentSection, sectionbody.key, 0], cells), {
211
+ key: intersectionCellId,
213
212
  headers: rowIds + ' ' + columnIds + ' ' + currentSection,
214
213
  cellHandler: cellHandler,
215
214
  HTMLRenderer: HTMLRenderer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-visions",
3
- "version": "7.10.0",
3
+ "version": "7.11.1",
4
4
  "description": "Library of visual components",
5
5
  "author": "OECD",
6
6
  "homepage": "https://visions-qa.siscc.org/#o",