@hipay/hipay-material-ui 1.0.0-beta.17 → 1.0.0-beta.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,7 @@ CellStatus.propTypes = process.env.NODE_ENV !== "production" ? {
60
60
  /**
61
61
  * Nombre d'opérations financières
62
62
  */
63
- nbOperations: PropTypes.number.isRequired,
63
+ nbOperations: PropTypes.number,
64
64
  /**
65
65
  * Statut courant de la transaction
66
66
  */
@@ -50,6 +50,10 @@ class BodyRow extends React.PureComponent {
50
50
  constructor(props) {
51
51
  super();
52
52
 
53
+ this.handleOpenRowDetails = type => () => {
54
+ this.props.onOpenRowDetails(this.props.row.rowId, type);
55
+ };
56
+
53
57
  this.state = {
54
58
  live: props.live,
55
59
  style: {
@@ -97,10 +101,6 @@ class BodyRow extends React.PureComponent {
97
101
  }
98
102
  }
99
103
 
100
- handleOpenRowDetails() {
101
- this.props.onOpenRowDetails(this.props.row.rowId);
102
- }
103
-
104
104
  handleSelect() {
105
105
  this.props.onSelect(this.props.row);
106
106
  }
@@ -123,9 +123,10 @@ class BodyRow extends React.PureComponent {
123
123
  numberLocale,
124
124
  sticky,
125
125
  innerRow,
126
- isDetail
126
+ isDetail,
127
+ detailRowsOptions
127
128
  } = _props,
128
- other = _objectWithoutProperties(_props, ['classes', 'theme', 'row', 'columns', 'lookupColumns', 'orderedColumns', 'selectable', 'selected', 'onClick', 'view', 'dense', 'dateLocale', 'numberLocale', 'sticky', 'innerRow', 'isDetail']);
129
+ other = _objectWithoutProperties(_props, ['classes', 'theme', 'row', 'columns', 'lookupColumns', 'orderedColumns', 'selectable', 'selected', 'onClick', 'view', 'dense', 'dateLocale', 'numberLocale', 'sticky', 'innerRow', 'isDetail', 'detailRowsOptions']);
129
130
 
130
131
  const { style } = this.state;
131
132
 
@@ -143,6 +144,19 @@ class BodyRow extends React.PureComponent {
143
144
  // If there is no datas don't display the row
144
145
  if (!row.hasOwnProperty('datas')) return false;
145
146
 
147
+ let detailsInfos = {};
148
+ if (row.details && row.details.length > 0) {
149
+ detailsInfos = row.details.reduce((memo, item) => {
150
+ if (item.rows.length > 0 && detailRowsOptions[item.type] && detailRowsOptions[item.type].anchor) {
151
+ memo[detailRowsOptions[item.type].anchor] = _extends({
152
+ type: item.type,
153
+ total: item.rows.length
154
+ }, detailRowsOptions[item.type]);
155
+ }
156
+ return memo;
157
+ }, {});
158
+ }
159
+
146
160
  return React.createElement(
147
161
  TableRow,
148
162
  {
@@ -230,8 +244,11 @@ class BodyRow extends React.PureComponent {
230
244
  numberLocale: numberLocale,
231
245
  dense: dense,
232
246
  selected: selected,
233
- onSelect: this.handleSelect,
234
- onOpenDetails: this.handleOpenRowDetails,
247
+ onSelect: this.handleSelect
248
+ }, detailsInfos[colId] && {
249
+ onOpenDetails: this.handleOpenRowDetails(detailsInfos[colId].type),
250
+ detailInfos: detailsInfos[colId]
251
+ }, {
235
252
  childrenCount: isParentAnchor ? row.children.length : null,
236
253
  colId: colId,
237
254
  lookedUp: lookedUp
@@ -259,7 +276,8 @@ BodyRow.defaultProps = {
259
276
  live: false,
260
277
  innerRow: false,
261
278
  lookupColumns: [],
262
- fixedColumnWidth: true
279
+ fixedColumnWidth: true,
280
+ detailRowsOptions: {}
263
281
  };
264
282
  BodyRow.propTypes = process.env.NODE_ENV !== "production" ? {
265
283
  /**
@@ -270,6 +288,10 @@ BodyRow.propTypes = process.env.NODE_ENV !== "production" ? {
270
288
  * Densité d'affichage (joue sur la hauteur des lignes)
271
289
  */
272
290
  dense: PropTypes.bool,
291
+ /**
292
+ * Options utilisées pour décrire le comportement de lignes de détails
293
+ */
294
+ detailRowsOptions: PropTypes.object,
273
295
  /**
274
296
  * Fixe la taille des colonnes selon le type de vue
275
297
  * Sinon les colonnes s'adaptent à l'espace disponible
@@ -112,9 +112,9 @@ class ChildRow extends React.PureComponent {
112
112
  parentIndicatorColumn, parentLabel, parentLabelIcon,
113
113
  children, columns, orderedColumns,
114
114
  selectable, selected,
115
- dateLocale, dense, sticky, view
115
+ dateLocale, dense, sticky, view, row
116
116
  } = _props,
117
- other = _objectWithoutProperties(_props, ['classes', 'theme', 'onClose', 'parentRowId', 'parentRowDatas', 'parentIndicatorColumn', 'parentLabel', 'parentLabelIcon', 'children', 'columns', 'orderedColumns', 'selectable', 'selected', 'dateLocale', 'dense', 'sticky', 'view']);
117
+ other = _objectWithoutProperties(_props, ['classes', 'theme', 'onClose', 'parentRowId', 'parentRowDatas', 'parentIndicatorColumn', 'parentLabel', 'parentLabelIcon', 'children', 'columns', 'orderedColumns', 'selectable', 'selected', 'dateLocale', 'dense', 'sticky', 'view', 'row']);
118
118
 
119
119
  let indicator = '';
120
120
  if (parentIndicatorColumn && columns.hasOwnProperty(parentIndicatorColumn)) {
@@ -141,10 +141,7 @@ class ChildRow extends React.PureComponent {
141
141
  TableBody,
142
142
  null,
143
143
  React.createElement(BodyRow, _extends({
144
- row: {
145
- rowId: parentRowId,
146
- datas: parentRowDatas
147
- },
144
+ row: row,
148
145
  selectable: selectable,
149
146
  selected: selected,
150
147
  columns: columns,
@@ -277,10 +274,6 @@ ChildRow.propTypes = process.env.NODE_ENV !== "production" ? {
277
274
  * Données de la ligne parente
278
275
  */
279
276
  parentRowDatas: PropTypes.object.isRequired,
280
- /**
281
- * Ligne des détails de la ligne parente
282
- */
283
- parentDetailRows: PropTypes.array,
284
277
  /**
285
278
  * Indicateur du sous-ensemble (en général la date)
286
279
  */
@@ -586,7 +586,8 @@ class HiTable extends React.Component {
586
586
  loading,
587
587
  fixedColumnWidth,
588
588
  disableContextMenu,
589
- footerContent
589
+ footerContent,
590
+ detailRowsOptions
590
591
  } = this.props;
591
592
 
592
593
  const { dateUpdate, isScrollToBottom, groupByIds } = this.state;
@@ -668,7 +669,8 @@ class HiTable extends React.Component {
668
669
  lookupColumns: lookupColumns,
669
670
  loading: loading,
670
671
  fixedColumnWidth: fixedColumnWidth,
671
- disableContextMenu: disableContextMenu
672
+ disableContextMenu: disableContextMenu,
673
+ detailRowsOptions: detailRowsOptions
672
674
  }),
673
675
  infiniteScroll && React.createElement(HiTableFooterScroll, {
674
676
  tabId: tabId,
@@ -725,6 +727,7 @@ HiTable.defaultProps = {
725
727
  dateLocale: 'en-EN',
726
728
  numberLocale: 'en-EN',
727
729
  dense: false,
730
+ detailRowsOptions: {},
728
731
  height: 450,
729
732
  sticky: true,
730
733
  translations: {
@@ -767,6 +770,17 @@ HiTable.propTypes = process.env.NODE_ENV !== "production" ? {
767
770
  * Locale utilisé pour le format des dates
768
771
  */
769
772
  dateLocale: PropTypes.string,
773
+ /**
774
+ * Options utilisées pour décrire le comportement de lignes de détails
775
+ * ex: {
776
+ * payment_operation: {
777
+ * anchor: 'transaction_id'
778
+ * }
779
+ * }
780
+ * dans cet exemple, on veut que les lignes de détails de type payment_operation
781
+ * soient affichable à partir d'un chip button dans les cellules transaction_id
782
+ */
783
+ detailRowsOptions: PropTypes.object,
770
784
  /**
771
785
  * Densité d'affichage (joue sur la hauteur des lignes)
772
786
  */
@@ -150,14 +150,16 @@ class HiTableBody extends React.Component {
150
150
  /**
151
151
  * Définit les id des lignes dont les détails sont affichés ou null
152
152
  * (ajoute une ligne pour chaque détails)
153
+ * vérifie aussi le type du détail
153
154
  *
154
155
  * @param rowId
156
+ * @param type
155
157
  */
156
- toggleOpenedDetailsRowId(rowId) {
158
+ toggleOpenedDetailsRowId(rowId, type) {
157
159
  this.setState(prevState => ({
158
- openedDetailsRowIdList: prevState.openedDetailsRowIdList.includes(rowId) ? prevState.openedDetailsRowIdList.filter(id => {
159
- return id !== rowId;
160
- }) : [...prevState.openedDetailsRowIdList, rowId]
160
+ openedDetailsRowIdList: prevState.openedDetailsRowIdList.find(item => item.id === rowId && item.type === type) ? prevState.openedDetailsRowIdList.filter(item => {
161
+ return item.id !== rowId || item.type !== type;
162
+ }) : [...prevState.openedDetailsRowIdList, { id: rowId, type: type }]
161
163
  }));
162
164
  this.props.addNewRowRefs();
163
165
  }
@@ -195,7 +197,8 @@ class HiTableBody extends React.Component {
195
197
  lookupColumns,
196
198
  loading,
197
199
  fixedColumnWidth,
198
- disableContextMenu
200
+ disableContextMenu,
201
+ detailRowsOptions
199
202
  } = this.props;
200
203
 
201
204
  const { openedParentRowId, openedDetailsRowIdList } = this.state;
@@ -266,9 +269,6 @@ class HiTableBody extends React.Component {
266
269
  // has children
267
270
  const hasChildren = row.hasOwnProperty('children') && row.children.length > 0;
268
271
 
269
- // has detail rows
270
- const hasDetailRows = row.hasOwnProperty('detailRows') && row.detailRows.length > 0;
271
-
272
272
  const BodyRowProps = _extends({
273
273
  columns,
274
274
  dateLocale,
@@ -280,9 +280,9 @@ class HiTableBody extends React.Component {
280
280
  }, hasChildren && {
281
281
  openedAsParent: openedParentRowId === row.rowId,
282
282
  onClick: this.setOpenedParentRowId // if row has children, onClick display the children
283
- }, hasDetailRows && {
284
- onOpenRowDetails: this.toggleOpenedDetailsRowId
285
283
  }, {
284
+ onOpenRowDetails: this.toggleOpenedDetailsRowId,
285
+ detailRowsOptions,
286
286
  orderedColumns
287
287
  }, selectable && {
288
288
  selectable,
@@ -305,7 +305,6 @@ class HiTableBody extends React.Component {
305
305
  parentIndicatorColumn: row.parentIndicatorColumn,
306
306
  parentLabel: row.parentLabel,
307
307
  parentLabelIcon: row.parentLabelIcon,
308
- parentDetailRows: row.detailRows,
309
308
  children: row.children,
310
309
  onClose: this.setOpenedParentRowId
311
310
  }, BodyRowProps)));
@@ -314,21 +313,25 @@ class HiTableBody extends React.Component {
314
313
  }
315
314
 
316
315
  // add opened detail rows
317
- if (hasDetailRows && openedDetailsRowIdList.includes(row.rowId)) {
318
- row.detailRows.forEach(detailRow => {
319
- const detailRowProps = {
320
- row: detailRow,
321
- columns,
322
- orderedColumns,
323
- view,
324
- dense,
325
- sticky,
326
- isDetail: true,
327
- fixedColumnWidth,
328
- disableContextMenu
329
- };
316
+ if (row.details && row.details.length > 0) {
317
+ row.details.forEach(detail => {
318
+ if (detail.rows.length > 0 && openedDetailsRowIdList.find(item => item.id === row.rowId && item.type === detail.type)) {
319
+ detail.rows.forEach(detailRow => {
320
+ const detailRowProps = {
321
+ row: detailRow,
322
+ columns,
323
+ orderedColumns,
324
+ view,
325
+ dense,
326
+ sticky,
327
+ isDetail: true,
328
+ fixedColumnWidth,
329
+ disableContextMenu
330
+ };
330
331
 
331
- tableRows.push(React.createElement(BodyRow, _extends({ key: `${row.rowId}-${detailRow.rowId}` }, detailRowProps)));
332
+ tableRows.push(React.createElement(BodyRow, _extends({ key: `${row.rowId}-${detailRow.rowId}` }, detailRowProps)));
333
+ });
334
+ }
332
335
  });
333
336
  }
334
337
  });
@@ -367,7 +370,8 @@ HiTableBody.defaultProps = {
367
370
  sticky: true,
368
371
  view: 'l',
369
372
  loading: false,
370
- disableContextMenu: true
373
+ disableContextMenu: true,
374
+ detailRowsOptions: {}
371
375
  };
372
376
  HiTableBody.propTypes = process.env.NODE_ENV !== "production" ? {
373
377
  /**
@@ -395,6 +399,10 @@ HiTableBody.propTypes = process.env.NODE_ENV !== "production" ? {
395
399
  * Densité d'affichage (joue sur la hauteur des lignes)
396
400
  */
397
401
  dense: PropTypes.bool,
402
+ /**
403
+ * Options utilisées pour décrire le comportement de lignes de détails
404
+ */
405
+ detailRowsOptions: PropTypes.object,
398
406
  /**
399
407
  * Active/désactive le menu contextuel au clic droit sur les cellules du tableau
400
408
  */
@@ -77,9 +77,8 @@ export const styles = theme => ({
77
77
  color: theme.palette.text.secondary,
78
78
  minWidth: 32
79
79
  },
80
- beta: {
81
- minWidth: 64,
82
- maxWidth: 80
80
+ betaWithoutAccountSelector: {
81
+ marginLeft: 1.5 * theme.spacing.unit
83
82
  },
84
83
  searchInput: {
85
84
  backgroundColor: `${theme.palette.background1} !important`
@@ -264,7 +263,9 @@ class HiTopBar extends React.Component {
264
263
  accountSelectorContent
265
264
  ),
266
265
  beta && React.createElement(HiColoredLabel, {
267
- className: classes.beta,
266
+ className: classNames({
267
+ [classes.betaWithoutAccountSelector]: !hasAccountSelector
268
+ }),
268
269
  label: 'BETA',
269
270
  beta: true,
270
271
  color: theme.palette.neutral.dark
package/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Material-UI v1.0.0-beta.15
1
+ /** @license Material-UI v1.0.0-beta.19
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Material-UI v1.0.0-beta.15
1
+ /** @license Material-UI v1.0.0-beta.19
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@hipay/hipay-material-ui",
3
3
  "private": false,
4
4
  "author": "HiPay PSYCHE Team",
5
- "version": "1.0.0-beta.17",
5
+ "version": "1.0.0-beta.19",
6
6
  "description": "HiPay Material-UI Style Guide - React components that implement Google's Material Design from Material-UI.",
7
7
  "main": "./index.js",
8
8
  "repository": {
@@ -18,8 +18,8 @@
18
18
  "react-dom": "15.3.0 || 16.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "react": "16.2.0",
22
21
  "@types/jss": "9.3.0",
22
+ "@types/react-transition-group": "2.0.6",
23
23
  "babel-runtime": "6.26.0",
24
24
  "brcast": "3.0.1",
25
25
  "classnames": "2.2.5",
@@ -34,11 +34,11 @@
34
34
  "jss-props-sort": "6.0.0",
35
35
  "jss-vendor-prefixer": "7.0.0",
36
36
  "keycode": "2.1.9",
37
- "lodash": "4.2.0",
37
+ "lodash": "4.17.4",
38
38
  "lz-string": "1.4.4",
39
39
  "material-ui": "1.0.0-beta.36",
40
40
  "mdi-material-ui": "2.0.0",
41
- "moment": "2.19.1",
41
+ "moment": "2.20.1",
42
42
  "moment-timezone": "0.5.14",
43
43
  "normalize-scroll-left": "0.1.2",
44
44
  "prop-types": "15.6.0",
@@ -46,15 +46,15 @@
46
46
  "react-contextmenu": "2.9.2",
47
47
  "react-custom-scrollbars": "4.2.1",
48
48
  "react-day-picker": "7.1.9",
49
- "react-event-listener": "0.5.1",
50
- "react-jss": "8.1.0",
49
+ "react-event-listener": "0.5.3",
50
+ "react-jss": "8.2.1",
51
51
  "react-lifecycles-compat": "1.0.2",
52
- "react-pdf": "3.0.4",
53
- "react-popper": "0.8.0",
52
+ "react-pdf": "3.0.5",
53
+ "react-popper": "0.8.2",
54
54
  "react-proptype-conditional-require": "1.0.4",
55
55
  "react-scrollbar-size": "2.0.2",
56
56
  "react-sortable-hoc": "0.6.8",
57
- "react-spinners": "0.2.5",
57
+ "react-spinners": "0.2.6",
58
58
  "react-transition-group": "2.2.1",
59
59
  "recompose": "0.26.0",
60
60
  "scroll": "2.0.3",