@sis-cc/dotstatsuite-visions 10.28.1 → 11.0.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.
@@ -5,30 +5,28 @@ import * as R from 'ramda';
5
5
  import Table from '@material-ui/core/Table';
6
6
  import TableRow from '@material-ui/core/TableRow';
7
7
  import TableCell from '@material-ui/core/TableCell';
8
+ import Lens from '@material-ui/icons/Lens';
8
9
  import { withBlank } from '../utils';
9
10
  import { useStyles } from './styles';
10
- import { getMaxValuesLength, getEmptyValues, getLabel, getEqualLengthValues, getEnhancedSections } from './lib';
11
+ import { getMaxValuesLength, getEmptyValues, getLabel, valueLabel, maxCount } from './lib';
11
12
 
12
13
  var patern = {
13
14
  id: PropTypes.string,
14
15
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
15
- values: PropTypes.arrayOf(PropTypes.shape({
16
- id: PropTypes.string,
17
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
18
- }))
16
+ count: PropTypes.number
19
17
  };
20
18
 
21
19
  var Header = function Header(_ref) {
22
20
  var header = _ref.header,
23
- colSpan = _ref.colSpan;
21
+ colSpan = _ref.colSpan,
22
+ valuesSpan = _ref.valuesSpan;
24
23
 
25
24
  var classes = useStyles();
26
25
 
27
26
  return R.map(function (_ref2) {
28
27
  var id = _ref2.id,
29
28
  label = _ref2.label,
30
- _ref2$values = _ref2.values,
31
- values = _ref2$values === undefined ? [] : _ref2$values;
29
+ count = _ref2.count;
32
30
  return React.createElement(
33
31
  TableRow,
34
32
  { key: id, className: cx(classes.header, classes.border) },
@@ -43,43 +41,41 @@ var Header = function Header(_ref) {
43
41
  },
44
42
  label
45
43
  ),
46
- R.map(function (_ref3) {
47
- var id = _ref3.id,
48
- label = _ref3.label;
44
+ R.times(function (index) {
49
45
  return React.createElement(
50
46
  TableCell,
51
47
  {
52
- key: id,
48
+ key: id + '-' + index,
53
49
  className: cx(classes.border, classes.cell, classes.headerCell),
54
- title: label,
55
50
  scope: 'col'
56
51
  },
57
- label
52
+ index < count ? valueLabel : ''
58
53
  );
59
- })(values)
54
+ }, valuesSpan)
60
55
  );
61
56
  })(header);
62
57
  };
63
58
 
64
59
  Header.propTypes = process.env.NODE_ENV !== "production" ? {
65
60
  header: PropTypes.array,
66
- colSpan: PropTypes.number
61
+ colSpan: PropTypes.number,
62
+ valuesSpan: PropTypes.number
67
63
  } : {};
68
64
 
69
- var RowHeader = function RowHeader(_ref4) {
70
- var _ref4$id = _ref4.id,
71
- id = _ref4$id === undefined ? 'rowHeader' : _ref4$id,
72
- rows = _ref4.rows,
73
- emptyValues = _ref4.emptyValues;
65
+ var RowHeader = function RowHeader(_ref3) {
66
+ var _ref3$id = _ref3.id,
67
+ id = _ref3$id === undefined ? 'rowHeader' : _ref3$id,
68
+ rows = _ref3.rows,
69
+ emptyValues = _ref3.emptyValues;
74
70
 
75
71
  var classes = useStyles();
76
72
 
77
73
  return React.createElement(
78
74
  TableRow,
79
75
  null,
80
- R.map(function (_ref5) {
81
- var id = _ref5.id,
82
- label = _ref5.label;
76
+ R.map(function (_ref4) {
77
+ var id = _ref4.id,
78
+ label = _ref4.label;
83
79
  return React.createElement(
84
80
  TableCell,
85
81
  {
@@ -107,9 +103,9 @@ RowHeader.propTypes = process.env.NODE_ENV !== "production" ? {
107
103
  emptyValues: PropTypes.array
108
104
  } : {};
109
105
 
110
- var Sections = function Sections(_ref6) {
111
- var sections = _ref6.sections,
112
- colSpan = _ref6.colSpan;
106
+ var Sections = function Sections(_ref5) {
107
+ var sections = _ref5.sections,
108
+ colSpan = _ref5.colSpan;
113
109
 
114
110
  var classes = useStyles();
115
111
 
@@ -119,11 +115,9 @@ var Sections = function Sections(_ref6) {
119
115
  React.createElement(
120
116
  TableCell,
121
117
  { tabIndex: 0, className: cx(classes.border, classes.sections), colSpan: colSpan },
122
- R.map(function (_ref7) {
123
- var id = _ref7.id,
124
- label = _ref7.label,
125
- values = _ref7.values,
126
- Icon = _ref7.Icon;
118
+ R.addIndex(R.map)(function (_ref6, index) {
119
+ var id = _ref6.id,
120
+ label = _ref6.label;
127
121
  return React.createElement(
128
122
  Fragment,
129
123
  { key: id },
@@ -135,8 +129,8 @@ var Sections = function Sections(_ref6) {
135
129
  React.createElement(
136
130
  'span',
137
131
  { className: classes.sectionsCell },
138
- values,
139
- R.isNil(Icon) ? null : React.createElement(Icon, { className: classes.icon })
132
+ valueLabel,
133
+ index === sections.length - 1 ? null : React.createElement(Lens, { className: classes.icon })
140
134
  )
141
135
  );
142
136
  })(sections)
@@ -149,41 +143,41 @@ Sections.propTypes = process.env.NODE_ENV !== "production" ? {
149
143
  colSpan: PropTypes.number
150
144
  } : {};
151
145
 
152
- var RowValues = function RowValues(_ref8) {
153
- var _ref8$id = _ref8.id,
154
- id = _ref8$id === undefined ? 'rowValues' : _ref8$id,
155
- rows = _ref8.rows,
156
- emptyValues = _ref8.emptyValues;
146
+ var RowValues = function RowValues(_ref7) {
147
+ var _ref7$id = _ref7.id,
148
+ id = _ref7$id === undefined ? 'rowValues' : _ref7$id,
149
+ rows = _ref7.rows,
150
+ emptyValues = _ref7.emptyValues;
157
151
 
158
152
  var classes = useStyles();
159
- var rowValues = R.pipe(R.map(function (_ref9) {
160
- var _ref9$values = _ref9.values,
161
- values = _ref9$values === undefined ? [] : _ref9$values;
162
- return R.map(R.identity)(values);
163
- }), R.transpose)(rows);
164
- return R.addIndex(R.map)(function (values, rowIndex) {
153
+
154
+ var totalMaxCount = R.min(maxCount, R.reduce(R.max, 0, R.pluck('count', rows)));
155
+
156
+ return R.times(function (rowIndex) {
165
157
  return React.createElement(
166
158
  TableRow,
167
159
  { key: id + '-' + rowIndex },
168
- R.map(function (_ref10) {
169
- var id = _ref10.id,
170
- label = _ref10.label;
160
+ R.map(function (_ref8) {
161
+ var id = _ref8.id,
162
+ count = _ref8.count;
171
163
  return React.createElement(
172
164
  TableCell,
173
165
  {
174
- key: id,
175
- className: cx(classes.rows, classes.border, classes.cell),
176
- title: label
166
+ key: id + '-' + rowIndex,
167
+ className: cx(classes.rows, classes.border, classes.cell)
177
168
  },
178
- label
169
+ rowIndex < count ? valueLabel : ''
179
170
  );
180
- })(values),
171
+ })(rows),
181
172
  React.createElement(TableCell, { className: cx(classes.separatorValues, classes.separatorSize, classes.border) }),
182
- R.addIndex(R.map)(function (value, valueIndex) {
183
- return React.createElement(TableCell, { key: rowIndex + '-' + valueIndex, className: cx(classes.border, classes.cell) });
184
- })(emptyValues)
173
+ R.times(function (columnIndex) {
174
+ return React.createElement(TableCell, {
175
+ key: rowIndex + '-header-' + columnIndex,
176
+ className: cx(classes.border, classes.cell)
177
+ });
178
+ })(emptyValues.length)
185
179
  );
186
- })(rowValues);
180
+ }, totalMaxCount);
187
181
  };
188
182
 
189
183
  RowValues.propTypes = process.env.NODE_ENV !== "production" ? {
@@ -192,26 +186,25 @@ RowValues.propTypes = process.env.NODE_ENV !== "production" ? {
192
186
  emptyValues: PropTypes.array
193
187
  } : {};
194
188
 
195
- var MyTable = function MyTable(_ref11) {
196
- var _ref11$header = _ref11.header,
197
- header = _ref11$header === undefined ? [] : _ref11$header,
198
- _ref11$sections = _ref11.sections,
199
- sections = _ref11$sections === undefined ? [] : _ref11$sections,
200
- _ref11$rows = _ref11.rows,
201
- rows = _ref11$rows === undefined ? [] : _ref11$rows,
202
- _ref11$labelRenderer = _ref11.labelRenderer,
203
- labelRenderer = _ref11$labelRenderer === undefined ? R.prop('name') : _ref11$labelRenderer;
189
+ var MyTable = function MyTable(_ref9) {
190
+ var _ref9$header = _ref9.header,
191
+ header = _ref9$header === undefined ? [] : _ref9$header,
192
+ _ref9$sections = _ref9.sections,
193
+ sections = _ref9$sections === undefined ? [] : _ref9$sections,
194
+ _ref9$rows = _ref9.rows,
195
+ rows = _ref9$rows === undefined ? [] : _ref9$rows,
196
+ _ref9$labelRenderer = _ref9.labelRenderer,
197
+ labelRenderer = _ref9$labelRenderer === undefined ? R.prop('name') : _ref9$labelRenderer;
204
198
 
205
199
  var classes = useStyles();
206
200
  var nbShowedValuesHeader = getMaxValuesLength(header);
207
- var nbShowedValuesRows = getMaxValuesLength(rows);
208
201
 
209
202
  var emptyValues = getEmptyValues(nbShowedValuesHeader);
210
- var nbColumns = R.max(R.length(header) + nbShowedValuesHeader, R.length(rows) + nbShowedValuesRows) + 2;
203
+ var nbColumns = R.length(rows) + R.max(nbShowedValuesHeader, 1) + 1;
211
204
  var nbColumnRows = R.length(rows) + 1;
212
- var enhancedHeader = R.pipe(getLabel(labelRenderer), getEqualLengthValues(nbShowedValuesHeader))(header);
213
- var enhancedRows = R.pipe(getLabel(labelRenderer), getEqualLengthValues(nbShowedValuesRows))(rows);
214
- var enhancedSections = R.pipe(getLabel(labelRenderer), getEnhancedSections(R.length(sections)))(sections);
205
+ var enhancedHeader = R.pipe(getLabel(labelRenderer))(header);
206
+ var enhancedRows = R.pipe(getLabel(labelRenderer))(rows);
207
+ var enhancedSections = R.pipe(getLabel(labelRenderer))(sections);
215
208
 
216
209
  return React.createElement(
217
210
  Table,
@@ -223,7 +216,11 @@ var MyTable = function MyTable(_ref11) {
223
216
  React.createElement(
224
217
  'tbody',
225
218
  null,
226
- R.isEmpty(enhancedHeader) ? null : React.createElement(Header, { colSpan: nbColumnRows, header: enhancedHeader }),
219
+ R.isEmpty(enhancedHeader) ? null : React.createElement(Header, {
220
+ colSpan: nbColumnRows,
221
+ header: enhancedHeader,
222
+ valuesSpan: nbShowedValuesHeader
223
+ }),
227
224
  React.createElement(RowHeader, { rows: enhancedRows, emptyValues: emptyValues }),
228
225
  R.isEmpty(enhancedSections) ? null : React.createElement(Sections, { colSpan: nbColumns, sections: enhancedSections }),
229
226
  React.createElement(RowValues, { rows: enhancedRows, emptyValues: emptyValues })
@@ -238,10 +235,10 @@ MyTable.propTypes = process.env.NODE_ENV !== "production" ? {
238
235
  labelRenderer: PropTypes.func
239
236
  } : {};
240
237
 
241
- export default withBlank(function (_ref12) {
242
- var _ref12$rows = _ref12.rows,
243
- rows = _ref12$rows === undefined ? [] : _ref12$rows,
244
- isBlank = _ref12.isBlank;
238
+ export default withBlank(function (_ref10) {
239
+ var _ref10$rows = _ref10.rows,
240
+ rows = _ref10$rows === undefined ? [] : _ref10$rows,
241
+ isBlank = _ref10.isBlank;
245
242
  return {
246
243
  isBlank: R.or(isBlank, R.isEmpty(rows))
247
244
  };
@@ -1,12 +1,11 @@
1
1
  import * as R from 'ramda';
2
2
  import Lens from '@material-ui/icons/Lens';
3
3
 
4
- export var getMaxValuesLength = function getMaxValuesLength(lists) {
5
- return Math.max.apply(Math, R.map(function (_ref) {
6
- var _ref$values = _ref.values,
7
- values = _ref$values === undefined ? [] : _ref$values;
8
- return R.length(values);
9
- })(lists));
4
+ export var valueLabel = 'Xxxx';
5
+ export var maxCount = 3;
6
+
7
+ export var getMaxValuesLength = function getMaxValuesLength(items) {
8
+ return Math.min(Math.max.apply(Math, R.pluck('count', items)), maxCount);
10
9
  };
11
10
  export var getEmptyValues = R.ifElse(R.flip(R.lte)(0), R.always(['']), R.times(R.always('')));
12
11
  export var getLabel = function getLabel(itemRenderer) {
@@ -34,6 +34,18 @@ var _useMediaQuery = require('@material-ui/core/useMediaQuery');
34
34
 
35
35
  var _useMediaQuery2 = _interopRequireDefault(_useMediaQuery);
36
36
 
37
+ var _IconButton = require('@material-ui/core/IconButton');
38
+
39
+ var _IconButton2 = _interopRequireDefault(_IconButton);
40
+
41
+ var _Collapse = require('@material-ui/core/Collapse');
42
+
43
+ var _Collapse2 = _interopRequireDefault(_Collapse);
44
+
45
+ var _Close = require('@material-ui/icons/Close');
46
+
47
+ var _Close2 = _interopRequireDefault(_Close);
48
+
37
49
  var _ = require('../');
38
50
 
39
51
  var _core = require('@material-ui/core');
@@ -67,12 +79,16 @@ var ShortUrls = function ShortUrls(_ref) {
67
79
  var labels = _ref.labels,
68
80
  onClick = _ref.onClick,
69
81
  isLoading = _ref.isLoading,
70
- contentValue = _ref.contentValue;
82
+ contentValue = _ref.contentValue,
83
+ _ref$isNotifOpen = _ref.isNotifOpen,
84
+ isNotifOpen = _ref$isNotifOpen === undefined ? false : _ref$isNotifOpen,
85
+ setIsNotifOpen = _ref.setIsNotifOpen;
71
86
 
72
87
  var isNarrow = (0, _useMediaQuery2.default)(function (theme) {
73
88
  return theme.breakpoints.down('sm');
74
89
  });
75
90
  var classes = useStyles();
91
+
76
92
  return _react2.default.createElement(
77
93
  _Grid2.default,
78
94
  { className: classes.container },
@@ -119,6 +135,29 @@ var ShortUrls = function ShortUrls(_ref) {
119
135
  value: contentValue
120
136
  })
121
137
  )
138
+ ),
139
+ _react2.default.createElement(
140
+ _Collapse2.default,
141
+ { 'in': isNotifOpen },
142
+ _react2.default.createElement(
143
+ _.Alert,
144
+ {
145
+ severity: 'error',
146
+ action: _react2.default.createElement(
147
+ _IconButton2.default,
148
+ {
149
+ 'aria-label': 'close',
150
+ color: 'inherit',
151
+ size: 'small',
152
+ onClick: function onClick() {
153
+ setIsNotifOpen(false);
154
+ }
155
+ },
156
+ _react2.default.createElement(_Close2.default, { fontSize: 'inherit' })
157
+ )
158
+ },
159
+ R.prop('errorMessage', labels)
160
+ )
122
161
  )
123
162
  );
124
163
  };
@@ -126,6 +165,8 @@ ShortUrls.propTypes = process.env.NODE_ENV !== "production" ? {
126
165
  onClick: _propTypes2.default.func,
127
166
  isLoading: _propTypes2.default.bool,
128
167
  contentValue: _propTypes2.default.string,
168
+ isNotifOpen: _propTypes2.default.bool,
169
+ setIsNotifOpen: _propTypes2.default.func,
129
170
  labels: _propTypes2.default.shape({
130
171
  generateUrl: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
131
172
  title: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
@@ -135,8 +135,6 @@ var TableHtml5 = function TableHtml5(_ref) {
135
135
  var headerRef = (0, _react.useRef)(null);
136
136
  var subHeadCellsRef = (0, _react.useRef)([]);
137
137
 
138
- var cellValueAccessorHandler = (0, _react.useCallback)(cellValueAccessor, []);
139
-
140
138
  (0, _react.useEffect)(function () {
141
139
  setHeaderHeight(R.pathOr(0, ['current', 'clientHeight'], headerRef));
142
140
  setSubHeadCellsWidth(getCellsWidth(R.prop('current', subHeadCellsRef)));
@@ -219,7 +217,7 @@ var TableHtml5 = function TableHtml5(_ref) {
219
217
  SideIcon: SideIcon,
220
218
  subHeadCellsWidth: subHeadCellsWidth,
221
219
  HTMLRenderer: HTMLRenderer,
222
- cellValueAccessor: cellValueAccessorHandler,
220
+ cellValueAccessor: cellValueAccessor,
223
221
  labelAccessor: labelAccessor,
224
222
  isNoWrap: isNoWrap,
225
223
  textAlign: textAlign