@hipay/hipay-material-ui 2.0.0-beta.35 → 2.0.0-beta.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. package/HiAppBar/HiAppBar.js +0 -2
  2. package/HiCell/CellAddress.js +140 -0
  3. package/HiCell/CellDate.js +140 -0
  4. package/HiCell/CellIcon.js +122 -0
  5. package/HiCell/CellImage.js +132 -0
  6. package/HiCell/CellNumeric.js +122 -0
  7. package/HiCell/CellPinToAction.js +92 -0
  8. package/HiCell/CellRate.js +184 -0
  9. package/HiCell/CellSentinel.js +179 -0
  10. package/HiCell/CellText.js +250 -0
  11. package/HiCell/index.js +71 -0
  12. package/HiCheckbox/HiCheckbox.js +15 -9
  13. package/HiDatePicker/Caption.js +0 -1
  14. package/HiDatePicker/HiDatePicker.js +1 -1
  15. package/HiDatePicker/HiDateRangePicker.js +756 -0
  16. package/HiDatePicker/HiDateRangeSelector.js +495 -0
  17. package/HiDatePicker/ListPicker.js +0 -1
  18. package/HiDatePicker/ListPicker.spec.js +1 -2
  19. package/HiDatePicker/NavBar.js +2 -2
  20. package/HiDatePicker/NavBar.spec.js +4 -5
  21. package/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
  22. package/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
  23. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
  24. package/HiDatePicker/Overlays/Overlay.js +0 -1
  25. package/HiDatePicker/Overlays/Overlay.spec.js +0 -5
  26. package/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
  27. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
  28. package/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
  29. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
  30. package/HiDatePicker/Weekday.js +0 -1
  31. package/HiDatePicker/stylesheet.js +7 -3
  32. package/HiForm/HiFormControl.js +23 -3
  33. package/HiForm/HiInput.js +2 -2
  34. package/HiIcon/HiIcon.js +7 -23
  35. package/HiSelect/HiSelect.js +1 -1
  36. package/HiSelect/HiSuggestSelect.js +8 -8
  37. package/HiSelectableList/HiSelectableList.js +3 -1
  38. package/HiSelectableList/HiSelectableListItem.js +21 -14
  39. package/es/HiAppBar/HiAppBar.js +0 -2
  40. package/es/HiCell/CellAddress.js +97 -0
  41. package/es/HiCell/CellDate.js +94 -0
  42. package/es/HiCell/CellIcon.js +83 -0
  43. package/es/HiCell/CellImage.js +91 -0
  44. package/es/HiCell/CellNumeric.js +80 -0
  45. package/es/HiCell/CellPinToAction.js +53 -0
  46. package/es/HiCell/CellRate.js +142 -0
  47. package/es/HiCell/CellSentinel.js +140 -0
  48. package/es/HiCell/CellText.js +198 -0
  49. package/es/HiCell/index.js +8 -0
  50. package/es/HiCheckbox/HiCheckbox.js +16 -10
  51. package/es/HiDatePicker/Caption.js +0 -1
  52. package/es/HiDatePicker/HiDatePicker.js +3 -3
  53. package/es/HiDatePicker/HiDateRangePicker.js +661 -0
  54. package/es/HiDatePicker/HiDateRangeSelector.js +432 -0
  55. package/es/HiDatePicker/ListPicker.js +0 -1
  56. package/es/HiDatePicker/ListPicker.spec.js +1 -2
  57. package/es/HiDatePicker/NavBar.js +2 -2
  58. package/es/HiDatePicker/NavBar.spec.js +4 -5
  59. package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
  60. package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
  61. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
  62. package/es/HiDatePicker/Overlays/Overlay.js +0 -1
  63. package/es/HiDatePicker/Overlays/Overlay.spec.js +0 -3
  64. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
  65. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
  66. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
  67. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
  68. package/es/HiDatePicker/Overlays/index.js +0 -1
  69. package/es/HiDatePicker/Weekday.js +0 -1
  70. package/es/HiDatePicker/stylesheet.js +7 -3
  71. package/es/HiForm/HiFormControl.js +22 -3
  72. package/es/HiForm/HiInput.js +2 -2
  73. package/es/HiIcon/HiIcon.js +7 -23
  74. package/es/HiSelect/HiSelect.js +1 -1
  75. package/es/HiSelect/HiSuggestSelect.js +8 -8
  76. package/es/HiSelectableList/HiSelectableList.js +3 -1
  77. package/es/HiSelectableList/HiSelectableListItem.js +21 -14
  78. package/es/index.js +2 -1
  79. package/es/styles/createPalette.js +4 -3
  80. package/es/utils/helpers.js +117 -0
  81. package/index.es.js +3 -2
  82. package/index.js +1 -1
  83. package/package.json +3 -1
  84. package/styles/createPalette.js +3 -3
  85. package/umd/hipay-material-ui.development.js +63 -48
  86. package/umd/hipay-material-ui.production.min.js +2 -2
  87. package/utils/helpers.js +134 -0
@@ -45,6 +45,8 @@ var _HiFormLabel = _interopRequireDefault(require("./HiFormLabel"));
45
45
 
46
46
  var _helpers = require("../utils/helpers");
47
47
 
48
+ var _index = _interopRequireDefault(require("keycode/index"));
49
+
48
50
  // @inheritedComponent FormControl
49
51
  var styles = function styles(theme) {
50
52
  return {
@@ -145,6 +147,14 @@ function (_React$PureComponent) {
145
147
  }
146
148
  };
147
149
 
150
+ _this.handleKeyDown = function (event) {
151
+ var key = (0, _index.default)(event);
152
+
153
+ if (['space', 'enter'].includes(key)) {
154
+ _this.handleHelperClick(event);
155
+ }
156
+ };
157
+
148
158
  _this.handleHover = function (value) {
149
159
  return function () {
150
160
  _this.setState({
@@ -173,6 +183,7 @@ function (_React$PureComponent) {
173
183
  hovered: false
174
184
  };
175
185
  _this.handleHelperClick = _this.handleHelperClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
186
+ _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
176
187
  _this.handleFocus = _this.handleFocus.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
177
188
  _this.handleHover = _this.handleHover.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
178
189
  return _this;
@@ -214,7 +225,12 @@ function (_React$PureComponent) {
214
225
  className: classes.errorDiv
215
226
  }, _react.default.createElement("div", {
216
227
  className: (0, _classnames.default)(classes.arrowDown, classes.errorDivArrowDown)
217
- }), errorText), helperIcon && helperText && !error && helperOpen && _react.default.createElement("div", {
228
+ }), _react.default.createElement("span", {
229
+ // eslint-disable-next-line react/no-danger
230
+ dangerouslySetInnerHTML: {
231
+ __html: (0, _helpers.escapeHTML)(errorText)
232
+ }
233
+ })), helperIcon && helperText && !error && helperOpen && _react.default.createElement("div", {
218
234
  className: classes.helperDiv
219
235
  }, _react.default.createElement("div", {
220
236
  className: (0, _classnames.default)(classes.arrowDown, classes.helperDivArrowDown)
@@ -231,10 +247,14 @@ function (_React$PureComponent) {
231
247
  focused: !disabled && (focused || hovered)
232
248
  }, InputLabelProps), error && _react.default.createElement(_Warning.default, {
233
249
  className: classes.errorIcon,
234
- onClick: this.handleHelperClick
250
+ onClick: this.handleHelperClick,
251
+ tabIndex: 0,
252
+ onKeyDown: this.handleKeyDown
235
253
  }), helperIcon && helperText && !error && _react.default.createElement(_Info.default, {
236
254
  className: (0, _classnames.default)(classes.helperIcon, (0, _defineProperty2.default)({}, classes.helperIconActive, helperOpen)),
237
- onClick: this.handleHelperClick
255
+ onClick: this.handleHelperClick,
256
+ tabIndex: 0,
257
+ onKeyDown: this.handleKeyDown
238
258
  })), _react.default.createElement("div", {
239
259
  onMouseEnter: this.handleHover(true),
240
260
  onMouseLeave: this.handleHover(false),
package/HiForm/HiInput.js CHANGED
@@ -88,8 +88,8 @@ var styles = function styles(theme) {
88
88
  startAdornment: {
89
89
  color: theme.palette.neutral.main,
90
90
  zIndex: 1,
91
- marginLeft: 8,
92
- marginRight: 16
91
+ marginLeft: 0,
92
+ marginRight: 8
93
93
  },
94
94
  startAdornmentFocus: {
95
95
  color: theme.palette.neutral.dark
package/HiIcon/HiIcon.js CHANGED
@@ -38,7 +38,7 @@ var styles = function styles(theme) {
38
38
 
39
39
  /* Styles applied to the root element. */
40
40
  faIcon: {
41
- fontSize: 24
41
+ fontSize: 20
42
42
  },
43
43
 
44
44
  /* Styles applied to the root element if `color="primary"`. */
@@ -80,11 +80,10 @@ function HiIcon(props) {
80
80
  classes = props.classes,
81
81
  className = props.className,
82
82
  color = props.color,
83
- fontSize = props.fontSize,
84
83
  icon = props.icon,
85
84
  size = props.size,
86
85
  theme = props.theme,
87
- other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "color", "fontSize", "icon", "size", "theme"]);
86
+ other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "color", "icon", "size", "theme"]);
88
87
  var iconName = icon !== null ? icon : children;
89
88
  var isHiColor = ['positive', 'negative', 'middle', 'neutral'].includes(color); // Line Awesome icons
90
89
 
@@ -92,7 +91,7 @@ function HiIcon(props) {
92
91
  return _react.default.createElement("i", (0, _extends2.default)({
93
92
  className: (0, _classnames.default)('fa', iconName, classes.root, (0, _defineProperty2.default)({}, classes["color".concat((0, _helpers.capitalize)(color))], color !== 'inherit'), className),
94
93
  style: {
95
- fontSize: fontSize !== 'inherit' ? size : 'inherit'
94
+ fontSize: size
96
95
  }
97
96
  }, other));
98
97
  } // Specific HiPay icons
@@ -102,12 +101,9 @@ function HiIcon(props) {
102
101
  var IconName = hiSvgIcons[(0, _helpers.capitalize)((0, _helpers.camelize)(iconName))];
103
102
  return _react.default.createElement(IconName, (0, _extends2.default)({
104
103
  className: (0, _classnames.default)(classes.root, className),
105
- color: isHiColor || color === 'primary' || color === 'secondary' ? theme.palette[color].main : theme.palette.primary.main
106
- }, fontSize === 'default' ? {
104
+ color: isHiColor || color === 'primary' || color === 'secondary' ? theme.palette[color].main : theme.palette.primary.main,
107
105
  width: size,
108
106
  height: size
109
- } : {
110
- fontSize: fontSize
111
107
  }, other));
112
108
  } // MDI - Material Design Icons - https://materialdesignicons.com
113
109
 
@@ -116,26 +112,20 @@ function HiIcon(props) {
116
112
  var _IconName = mdi[(0, _helpers.capitalize)((0, _helpers.camelize)(iconName.slice(4)))];
117
113
  return _react.default.createElement(_IconName, (0, _extends2.default)({
118
114
  className: (0, _classnames.default)(classes.root, (0, _defineProperty2.default)({}, classes["color".concat((0, _helpers.capitalize)(color))], isHiColor), className),
119
- color: isHiColor ? 'inherit' : color
120
- }, fontSize === 'default' ? {
115
+ color: isHiColor ? 'inherit' : color,
121
116
  style: {
122
117
  fontSize: size
123
118
  }
124
- } : {
125
- fontSize: fontSize
126
119
  }, other));
127
120
  } // @material-ui/icons
128
121
 
129
122
 
130
123
  return _react.default.createElement(_Icon.default, (0, _extends2.default)({
131
124
  className: (0, _classnames.default)(classes.root, (0, _defineProperty2.default)({}, classes["color".concat((0, _helpers.capitalize)(color))], isHiColor), className),
132
- color: isHiColor ? 'inherit' : color
133
- }, fontSize === 'default' ? {
125
+ color: isHiColor ? 'inherit' : color,
134
126
  style: {
135
127
  fontSize: size
136
128
  }
137
- } : {
138
- fontSize: fontSize
139
129
  }, other), iconName);
140
130
  }
141
131
 
@@ -161,11 +151,6 @@ HiIcon.propTypes = process.env.NODE_ENV !== "production" ? {
161
151
  */
162
152
  color: _propTypes.default.oneOf(['inherit', 'primary', 'secondary', 'action', 'error', 'disabled', 'positive', 'negative', 'middle', 'neutral']),
163
153
 
164
- /**
165
- * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
166
- */
167
- fontSize: _propTypes.default.oneOf(['inherit', 'default']),
168
-
169
154
  /**
170
155
  * Deprecated use (same as children)
171
156
  * The name of the icon font ligature.
@@ -179,9 +164,8 @@ HiIcon.propTypes = process.env.NODE_ENV !== "production" ? {
179
164
  } : {};
180
165
  HiIcon.defaultProps = {
181
166
  color: 'inherit',
182
- fontSize: 'default',
183
167
  icon: null,
184
- size: 24
168
+ size: 20
185
169
  };
186
170
  HiIcon.muiName = 'HiIcon';
187
171
 
@@ -72,7 +72,7 @@ var styles = function styles(theme) {
72
72
  position: 'relative'
73
73
  },
74
74
  popper: {
75
- width: '100%',
75
+ width: '100% !important',
76
76
  zIndex: 1200
77
77
  },
78
78
  paper: {
@@ -53,10 +53,10 @@ var styles = function styles(theme) {
53
53
  width: '100%'
54
54
  },
55
55
  popper: {
56
- width: '100%',
57
- transform: 'none',
58
- zIndex: 9,
59
- top: '100%'
56
+ width: '100% !important',
57
+ transform: 'none !important',
58
+ zIndex: '9 !important',
59
+ top: '100% !important'
60
60
  },
61
61
  paper: {
62
62
  borderRadius: '0px 2px',
@@ -236,12 +236,12 @@ function (_React$PureComponent) {
236
236
  onKeyDown: this.handleKeyDownSearch,
237
237
  onBlur: this.handleBlur,
238
238
  onFocus: this.handleFocus
239
- })), open && _react.default.createElement(_Popper.default, {
239
+ })), _react.default.createElement(_Popper.default, {
240
240
  disablePortal: true,
241
241
  anchorEl: this.textInput,
242
242
  placement: "bottom-start",
243
- eventsEnabled: open,
244
- className: classes.popper
243
+ className: classes.popper,
244
+ open: true
245
245
  }, _react.default.createElement(_Grow.default, {
246
246
  in: open,
247
247
  id: "menu-list",
@@ -253,7 +253,7 @@ function (_React$PureComponent) {
253
253
  }, _react.default.createElement(_HiSelectableList.default, {
254
254
  itemList: optionsShown,
255
255
  selectedIdList: [],
256
- checkbox: false,
256
+ hideCheckbox: true,
257
257
  onSelect: this.handleSelect,
258
258
  translations: translations,
259
259
  onKeyDown: this.handleKeyDown
@@ -33,7 +33,9 @@ var _HiSelectableListItem = _interopRequireDefault(require("./HiSelectableListIt
33
33
 
34
34
  var styles = function styles() {
35
35
  return {
36
- root: {}
36
+ root: {
37
+ padding: 0
38
+ }
37
39
  };
38
40
  };
39
41
  /**
@@ -47,9 +47,12 @@ var _helpers = require("../utils/helpers");
47
47
 
48
48
  var styles = function styles(theme) {
49
49
  return {
50
- root: {},
50
+ root: {
51
+ paddingLeft: 4
52
+ },
51
53
  listItem: {
52
54
  backgroundColor: theme.palette.background3,
55
+ color: theme.palette.neutral.dark,
53
56
  padding: '5px 0',
54
57
  fontWeight: theme.typography.fontWeightRegular,
55
58
  maxHeight: 56,
@@ -79,7 +82,6 @@ var styles = function styles(theme) {
79
82
  width: '100%'
80
83
  },
81
84
  disabled: {
82
- color: theme.palette.action.disabled,
83
85
  fontWeight: theme.typography.fontWeightLight,
84
86
  cursor: 'default'
85
87
  },
@@ -109,11 +111,12 @@ var styles = function styles(theme) {
109
111
  fontWeight: 'inherit',
110
112
  width: '100%',
111
113
  height: '-webkit-fill-available',
112
- padding: '4px 0'
114
+ padding: '5px 0'
113
115
  }),
114
116
  label: {
115
117
  display: 'inline-block',
116
- margin: '1px 0 1px 8px'
118
+ margin: '1px 0',
119
+ paddingLeft: 4
117
120
  },
118
121
  coloredLabel: {
119
122
  display: 'inline-flex',
@@ -128,7 +131,7 @@ var styles = function styles(theme) {
128
131
  color: theme.palette.neutral.main,
129
132
  fontWeight: theme.typography.fontWeightLight,
130
133
  fontSize: 11,
131
- marginLeft: 8
134
+ marginLeft: 4
132
135
  }),
133
136
  inline: {},
134
137
  info: (0, _extends2.default)({}, theme.typography.b3, {
@@ -144,19 +147,19 @@ var styles = function styles(theme) {
144
147
  alignSelf: 'center'
145
148
  }),
146
149
  checkbox: {
147
- width: 20,
148
- height: 20,
149
- fontSize: 20,
150
- margin: '5px 6px 5px 0'
150
+ marginTop: 3
151
+ },
152
+ checkboxWithSecondaryInline: {
153
+ marginTop: '-8px'
151
154
  },
152
155
  img: {
153
156
  width: 24,
154
157
  height: 'auto',
155
- margin: '2px 8px',
158
+ margin: '1px 4px 3px 4px',
156
159
  verticalAlign: 'middle'
157
160
  },
158
161
  icon: {
159
- margin: '0 8px',
162
+ margin: '0 4px',
160
163
  verticalAlign: 'middle'
161
164
  }
162
165
  };
@@ -308,7 +311,9 @@ function (_React$Component) {
308
311
  }), !hideCheckbox && !pinned && _react.default.createElement(_HiCheckbox.default, {
309
312
  checked: selected,
310
313
  checkedIcon: checkedIcon,
311
- className: classes.checkbox,
314
+ classes: {
315
+ root: !secondaryInline ? classes.checkboxWithSecondaryInline : classes.checkbox
316
+ },
312
317
  color: "primary" // TODO ?
313
318
  ,
314
319
  disabled: disabled,
@@ -338,9 +343,11 @@ HiSelectableListItem.defaultProps = {
338
343
  centered: false,
339
344
  disabled: false,
340
345
  hideCheckbox: false,
346
+ hoverIcon: 'check_box_outline_blank',
347
+ checkedIcon: 'check_box',
341
348
  indeterminate: false,
342
349
  level: 0,
343
- paddingLeft: 16,
350
+ paddingLeft: 4,
344
351
  pinned: false,
345
352
  secondaryInline: true,
346
353
  selected: false,
@@ -380,7 +387,7 @@ HiSelectableListItem.propTypes = process.env.NODE_ENV !== "production" ? {
380
387
  /**
381
388
  * Icon affiché lorsque l'item n'est pas sélectionné et qu'on le survole
382
389
  */
383
- hoverIcon: _propTypes.default.string,
390
+ hoverIcon: _propTypes.default.node,
384
391
 
385
392
  /**
386
393
  * Icon affiché lorsque l'item n'est pas sélectionné
@@ -53,12 +53,10 @@ class HiAppBar extends React.Component {
53
53
  handleCollapse() {
54
54
  if (this.props.onCollapse) {
55
55
  this.props.onCollapse();
56
- console.log('oncollapse');
57
56
  } else {
58
57
  this.setState(prevState => ({
59
58
  collapsed: !prevState.collapsed
60
59
  }));
61
- console.log('setState');
62
60
  }
63
61
  }
64
62
 
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import withStyles from '../styles/withStyles';
4
+ export const styles = () => ({
5
+ rightEllipsisSpan: {
6
+ display: 'inline-block',
7
+ overflow: 'hidden',
8
+ textOverflow: 'ellipsis',
9
+ whiteSpace: 'pre',
10
+ width: '100%'
11
+ }
12
+ });
13
+ /**
14
+ * Cette cellule permet d'afficher une adresse ou le nom d'un lieu
15
+ * - si le nom du lieu est défini, on affiche le lieu et la ville
16
+ * - sinon on affiche la ville et le pays
17
+ * - tous les champs définis sont affichés dans le tooltip
18
+ */
19
+
20
+ class CellAddress extends React.PureComponent {
21
+ render() {
22
+ const {
23
+ classes,
24
+ streetAddress,
25
+ name,
26
+ city,
27
+ postalCode,
28
+ view,
29
+ country,
30
+ isoCountry
31
+ } = this.props;
32
+ const labelItems = (view === 'l' ? [name, city, country] : [name, city, isoCountry]).filter(item => item !== undefined);
33
+ const label = labelItems && labelItems.length > 0 ? labelItems.join(', ') : '';
34
+ let title = '';
35
+ if (name) title += `${name}\n`;
36
+ if (streetAddress) title += `${streetAddress}\n`;
37
+ if (city && postalCode) title += `${city}, ${postalCode}\n`;
38
+ if (city && !postalCode) title += `${city}\n`;
39
+ if (postalCode && !city) title += `${postalCode}\n`;
40
+ if (country && isoCountry) title += `${country}, ${isoCountry}`;
41
+ if (country && !isoCountry) title += country;
42
+ if (isoCountry && !country) title += isoCountry;
43
+ return React.createElement("div", {
44
+ className: classes.rightEllipsisSpan,
45
+ title: title
46
+ }, label);
47
+ }
48
+
49
+ }
50
+
51
+ CellAddress.defaultProps = {
52
+ view: 'l'
53
+ };
54
+ CellAddress.propTypes = process.env.NODE_ENV !== "production" ? {
55
+ /**
56
+ * Ville
57
+ */
58
+ city: PropTypes.string,
59
+
60
+ /**
61
+ * Useful to extend the style applied to components.
62
+ */
63
+ classes: PropTypes.object,
64
+
65
+ /**
66
+ * Pays
67
+ */
68
+ country: PropTypes.string,
69
+
70
+ /**
71
+ * Code ISO du pays
72
+ */
73
+ isoCountry: PropTypes.string,
74
+
75
+ /**
76
+ * Nom du lieu
77
+ */
78
+ name: PropTypes.string,
79
+
80
+ /**
81
+ * Code postal
82
+ */
83
+ postalCode: PropTypes.string,
84
+
85
+ /**
86
+ * Numéro et nom de la rue
87
+ */
88
+ streetAddress: PropTypes.string,
89
+
90
+ /**
91
+ * View (L/M/S)
92
+ */
93
+ view: PropTypes.oneOf(['l', 'm', 's'])
94
+ } : {};
95
+ export default withStyles(styles, {
96
+ name: 'HmuiCellAddress'
97
+ })(CellAddress);
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import moment from 'moment';
4
+ import 'moment/locale/fr';
5
+ import withStyles from '../styles/withStyles';
6
+ export const styles = {
7
+ rightEllipsisSpan: {
8
+ display: 'inline-block',
9
+ overflow: 'hidden',
10
+ textOverflow: 'ellipsis',
11
+ whiteSpace: 'pre',
12
+ width: '100%'
13
+ }
14
+ };
15
+ /**
16
+ * Cette cellule permet d'afficher une date en fonction de la locale de l'utilisateur
17
+ */
18
+
19
+ class CellDate extends React.PureComponent {
20
+ constructor(...args) {
21
+ super(...args);
22
+ this.formatLong = 'dddd DD MMMM YYYY HH:mm:ss';
23
+ }
24
+
25
+ render() {
26
+ const {
27
+ classes,
28
+ displayTime,
29
+ date,
30
+ locale,
31
+ view,
32
+ formatShort
33
+ } = this.props;
34
+ if (!date) return '';
35
+ const mdate = moment(date);
36
+ mdate.locale(locale);
37
+ let label;
38
+
39
+ if (view === 'l') {
40
+ label = displayTime ? mdate.format(this.formatLong) : mdate.format(this.formatLong.replace(' HH:mm:ss', ''));
41
+ } else if (view === 'm') {
42
+ label = displayTime ? mdate.format(`${formatShort} HH:mm:ss`) : mdate.format(formatShort);
43
+ } else {
44
+ label = displayTime ? mdate.format(`${formatShort.replace('YYYY', 'YY')} HH:mm:ss`) : mdate.format(formatShort.replace('YYYY', 'YY'));
45
+ }
46
+
47
+ return React.createElement("div", {
48
+ className: classes.rightEllipsisSpan
49
+ }, label);
50
+ }
51
+
52
+ }
53
+
54
+ CellDate.defaultProps = {
55
+ displayTime: false,
56
+ formatShort: 'DD/MM/YYYY',
57
+ locale: 'en',
58
+ view: 'm'
59
+ };
60
+ CellDate.propTypes = process.env.NODE_ENV !== "production" ? {
61
+ /**
62
+ * Useful to extend the style applied to components.
63
+ */
64
+ classes: PropTypes.object,
65
+
66
+ /**
67
+ * Date as string
68
+ */
69
+ date: PropTypes.string,
70
+
71
+ /**
72
+ * Affiche l'heure
73
+ */
74
+ displayTime: PropTypes.bool,
75
+
76
+ /**
77
+ * Format de la date en vue small (ex: DD/MM/YYYY)
78
+ * @see https://momentjs.com/docs/#/parsing/string-format/
79
+ */
80
+ formatShort: PropTypes.string,
81
+
82
+ /**
83
+ * Locale moment
84
+ */
85
+ locale: PropTypes.string,
86
+
87
+ /**
88
+ * View (L/M/S)
89
+ */
90
+ view: PropTypes.oneOf(['l', 'm', 's'])
91
+ } : {};
92
+ export default withStyles(styles, {
93
+ name: 'HmuiCellDate'
94
+ })(CellDate);
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import withStyles from '../styles/withStyles';
4
+ import HiIcon from '../HiIcon';
5
+ export const styles = {
6
+ icon: {
7
+ float: 'left'
8
+ },
9
+ label: {
10
+ margin: '4px 0 4px 5px',
11
+ whiteSpace: 'nowrap',
12
+ overflow: 'hidden',
13
+ textOverflow: 'ellipsis'
14
+ },
15
+ wrapper: {
16
+ maxWidth: '100%',
17
+ display: 'inline-flex'
18
+ }
19
+ };
20
+ /**
21
+ * Cette cellule permet d'afficher une icône et un label (optionnel).
22
+ * En vue small (s) elle affiche uniquement l'icône avec une largeur fixe.
23
+ */
24
+
25
+ class CellIcon extends React.PureComponent {
26
+ render() {
27
+ const {
28
+ classes,
29
+ color,
30
+ icon,
31
+ label,
32
+ view
33
+ } = this.props;
34
+ return React.createElement("div", {
35
+ className: classes.wrapper,
36
+ title: label
37
+ }, icon && React.createElement(HiIcon, {
38
+ color: color,
39
+ className: classes.icon,
40
+ icon: icon,
41
+ width: 40,
42
+ height: 24
43
+ }), view !== 's' && label && React.createElement("span", {
44
+ className: classes.label
45
+ }, label));
46
+ }
47
+
48
+ }
49
+
50
+ CellIcon.defaultProps = {
51
+ view: 'm',
52
+ color: 'neutral'
53
+ };
54
+ CellIcon.propTypes = process.env.NODE_ENV !== "production" ? {
55
+ /**
56
+ * Useful to extend the style applied to components.
57
+ */
58
+ classes: PropTypes.object,
59
+
60
+ /**
61
+ * Couleur de l'icône
62
+ */
63
+ color: PropTypes.string,
64
+
65
+ /**
66
+ * Icon name [from material-design-icons](https://materialdesignicons.com/)
67
+ * used by HiIconBuilder
68
+ */
69
+ icon: PropTypes.string,
70
+
71
+ /**
72
+ * Label
73
+ */
74
+ label: PropTypes.string,
75
+
76
+ /**
77
+ * View (L/M/S)
78
+ */
79
+ view: PropTypes.oneOf(['l', 'm', 's'])
80
+ } : {};
81
+ export default withStyles(styles, {
82
+ name: 'HmuiCellIcon'
83
+ })(CellIcon);