@hipay/hipay-material-ui 1.0.0-beta.22 → 1.0.0-beta.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/HiChip/HiChip.js +6 -0
  2. package/HiChip/HiChipSwitch.js +6 -0
  3. package/HiDatePicker/HiDatePicker.js +35 -21
  4. package/HiDatePicker/HiDateRangePicker.js +66 -38
  5. package/HiDatePicker/HiDateRangeSelector.js +2 -2
  6. package/HiDatePicker/Overlays/Overlay.js +1 -1
  7. package/HiDatePicker/stylesheet.js +3 -0
  8. package/HiForm/HiInput.js +11 -2
  9. package/HiForm/HiPasswordField.js +6 -1
  10. package/HiLoader/HiLoader.js +7 -4
  11. package/HiSelect/HiSelect.js +19 -1
  12. package/HiSelect/HiSuggestSelect.js +2 -1
  13. package/HiSelectableList/HiSelectableListItem.js +14 -0
  14. package/HiTable/BodyCells/CellAccount.js +1 -1
  15. package/HiTable/BodyCells/CellStatus.js +1 -1
  16. package/HiTable/ColumnFilter.js +1 -1
  17. package/es/HiChip/HiChip.js +6 -1
  18. package/es/HiChip/HiChipSwitch.js +6 -0
  19. package/es/HiDatePicker/HiDatePicker.js +30 -21
  20. package/es/HiDatePicker/HiDateRangePicker.js +62 -41
  21. package/es/HiDatePicker/HiDateRangeSelector.js +2 -2
  22. package/es/HiDatePicker/Overlays/Overlay.js +1 -1
  23. package/es/HiDatePicker/stylesheet.js +3 -0
  24. package/es/HiForm/HiInput.js +11 -2
  25. package/es/HiForm/HiPasswordField.js +6 -1
  26. package/es/HiLoader/HiLoader.js +3 -3
  27. package/es/HiSelect/HiSelect.js +19 -1
  28. package/es/HiSelect/HiSuggestSelect.js +2 -1
  29. package/es/HiSelectableList/HiSelectableListItem.js +11 -0
  30. package/es/HiTable/BodyCells/CellAccount.js +1 -1
  31. package/es/HiTable/BodyCells/CellStatus.js +1 -1
  32. package/es/HiTable/ColumnFilter.js +1 -1
  33. package/index.es.js +1 -1
  34. package/index.js +1 -1
  35. package/package.json +1 -1
  36. package/umd/hipay-material-ui.development.js +15728 -15666
  37. package/umd/hipay-material-ui.production.min.js +5 -5
@@ -40,6 +40,7 @@ class HiDatePicker extends React.Component {
40
40
  this.renderMonthPickerOverlay = this.renderMonthPickerOverlay.bind(this);
41
41
  this.renderTimePickerOverlay = this.renderTimePickerOverlay.bind(this);
42
42
  this.renderYearPickerOverlay = this.renderYearPickerOverlay.bind(this);
43
+ this.handleInputChange = this.handleInputChange.bind(this);
43
44
  }
44
45
 
45
46
  componentWillUnmount() {
@@ -51,27 +52,33 @@ class HiDatePicker extends React.Component {
51
52
  this.props.onReset();
52
53
  }
53
54
 
55
+ handleInputChange(event) {
56
+ this.props.onChange(event.target.value);
57
+ }
58
+
54
59
  handleDayChange(day, modifiers) {
55
- if (modifiers.selected) {
56
- // Deselect day
57
- this.props.onChange(undefined);
58
- } else {
59
- // Keep Time if set
60
- if (this.props.enableTime && day !== undefined) {
61
- if (this.props.value) {
62
- day.setHours(this.props.value.getHours(), this.props.value.getMinutes());
63
- } else {
64
- day.setHours(0, 0);
60
+ if (day) {
61
+ if (modifiers.selected) {
62
+ // Deselect day
63
+ this.props.onChange(undefined);
64
+ } else {
65
+ // Keep Time if set
66
+ if (this.props.enableTime && day !== undefined) {
67
+ if (this.props.value) {
68
+ day.setHours(this.props.value.getHours(), this.props.value.getMinutes());
69
+ } else {
70
+ day.setHours(0, 0);
71
+ }
65
72
  }
73
+ this.props.onChange(day);
74
+ }
75
+ if (day instanceof Date && !this.props.enableTime && modifiers.selected !== true) {
76
+ // Hide overlay & remove focus on input
77
+ document.activeElement.blur();
78
+ } else if (day instanceof Date && this.props.enableTime && modifiers.selected !== true) {
79
+ // Open Time panel after date selection
80
+ this.openPanel('time');
66
81
  }
67
- this.props.onChange(day);
68
- }
69
- if (day instanceof Date && !this.props.enableTime && modifiers.selected !== true) {
70
- // Hide overlay & remove focus on input
71
- document.activeElement.blur();
72
- } else if (day instanceof Date && this.props.enableTime && modifiers.selected !== true) {
73
- // Open Time panel after date selection
74
- this.openPanel('time');
75
82
  }
76
83
  }
77
84
 
@@ -205,7 +212,7 @@ class HiDatePicker extends React.Component {
205
212
  captionElement: this.renderCaption,
206
213
  classNames: classes,
207
214
  disabledDays: effectiveDisabledDays,
208
- selectedDays: value,
215
+ selectedDays: typeof value === 'object' ? value : undefined,
209
216
  locale,
210
217
  firstDayOfWeek: 1,
211
218
  fromMonth: minimumDate,
@@ -221,7 +228,9 @@ class HiDatePicker extends React.Component {
221
228
  onReset: this.handleReset
222
229
  }, {
223
230
  onBlur: this.handleBlur
224
- }, props);
231
+ }, props, {
232
+ onChange: this.handleInputChange
233
+ });
225
234
 
226
235
  return React.createElement(
227
236
  'div',
@@ -314,6 +323,6 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
314
323
  /**
315
324
  * Date sélectionnée
316
325
  */
317
- value: PropTypes.instanceOf(Date)
326
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string])
318
327
  } : {};
319
328
  export default withStyles(styles, { name: 'HmuiHiDatePicker' })(HiDatePicker);
@@ -1,3 +1,4 @@
1
+ import _Object$values from 'babel-runtime/core-js/object/values';
1
2
  import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
2
3
  import _extends from 'babel-runtime/helpers/extends';
3
4
  // weak
@@ -25,6 +26,10 @@ class HiDateRangePicker extends React.Component {
25
26
  constructor(props) {
26
27
  super();
27
28
 
29
+ this.handleInputChange = inputName => event => {
30
+ this.props.onChange(inputName, event.target.value);
31
+ };
32
+
28
33
  this.handleDayPickerFocus = name => () => {
29
34
  this.setState({ focusedInput: name });
30
35
  };
@@ -58,6 +63,7 @@ class HiDateRangePicker extends React.Component {
58
63
  this.handleYearClickTo = this.handleYearClickTo.bind(this);
59
64
  this.handleDayPickerFocus = this.handleDayPickerFocus.bind(this);
60
65
  this.handleDayPickerBlur = this.handleDayPickerBlur.bind(this);
66
+ this.handleInputChange = this.handleInputChange.bind(this);
61
67
 
62
68
  this.openPanel = this.openPanel.bind(this);
63
69
 
@@ -108,38 +114,40 @@ class HiDateRangePicker extends React.Component {
108
114
  }
109
115
 
110
116
  handleDayChange(name, day, modifiers) {
111
- // if time disabled, focus TO input
112
- // else focus current input
113
- if (!this.props.enableTime) {
114
- if (day instanceof Date) {
115
- if (name === 'from' && this.toInput) {
116
- this.toInput.getInput().focus();
117
- } else if (name === 'to') {
118
- document.activeElement.blur();
117
+ if (day) {
118
+ // if time disabled, focus TO input
119
+ // else focus current input
120
+ if (!this.props.enableTime) {
121
+ if (day instanceof Date) {
122
+ if (name === 'from' && this.toInput) {
123
+ this.toInput.getInput().focus();
124
+ } else if (name === 'to') {
125
+ document.activeElement.blur();
126
+ }
119
127
  }
128
+ } else {
129
+ this.timeout = setTimeout(() => {
130
+ if (this[`${name}Input`].getInput()) {
131
+ this[`${name}Input`].getInput().focus();
132
+ }
133
+ }, 10);
120
134
  }
121
- } else {
122
- this.timeout = setTimeout(() => {
123
- if (this[`${name}Input`].getInput()) {
124
- this[`${name}Input`].getInput().focus();
125
- }
126
- }, 10);
127
- }
128
135
 
129
- if (this.props.onChange) {
130
- // Keep Time if set
131
- if (this.props.enableTime) {
132
- if (this.props[name]) {
133
- day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
134
- } else {
135
- day.setHours(0, 0);
136
+ if (this.props.onChange) {
137
+ // Keep Time if set
138
+ if (this.props.enableTime) {
139
+ if (this.props[name]) {
140
+ day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
141
+ } else {
142
+ day.setHours(0, 0);
143
+ }
136
144
  }
145
+ this.props.onChange(name, day);
137
146
  }
138
- this.props.onChange(name, day);
139
- }
140
147
 
141
- if (this.props.enableTime) {
142
- this.openPanel(name, 'time');
148
+ if (this.props.enableTime) {
149
+ this.openPanel(name, 'time');
150
+ }
143
151
  }
144
152
  }
145
153
  handleDayChangeFrom(day, modifiers) {
@@ -352,6 +360,20 @@ class HiDateRangePicker extends React.Component {
352
360
  }
353
361
  };
354
362
 
363
+ let selectedDays = [];
364
+ let selected = {};
365
+ if (from instanceof Date) {
366
+ selectedDays.push(from);
367
+ selected.from = from;
368
+ }
369
+ if (to instanceof Date) {
370
+ selectedDays.push(to);
371
+ selected.to = to;
372
+ }
373
+ if (_Object$values(selected).length > 0) {
374
+ selectedDays.push(selected);
375
+ }
376
+
355
377
  const dayPickerProps = _extends({
356
378
  classNames: classes,
357
379
  disabledDays,
@@ -361,7 +383,7 @@ class HiDateRangePicker extends React.Component {
361
383
  modifiers,
362
384
  modifiersStyles,
363
385
  // Both are required ?
364
- selectedDays: [from, { from, to }],
386
+ selectedDays,
365
387
  todayButton: translations.today,
366
388
  weekdayElement: Weekday
367
389
  }, props);
@@ -370,9 +392,9 @@ class HiDateRangePicker extends React.Component {
370
392
  // Disable days after 'to' date if define
371
393
 
372
394
  let after;
373
- if (to && disableFutureDays) {
395
+ if (to instanceof Date && disableFutureDays) {
374
396
  after = to < now ? now : to;
375
- } else if (to) {
397
+ } else if (to instanceof Date) {
376
398
  after = to;
377
399
  } else if (disableFutureDays) {
378
400
  after = now;
@@ -399,9 +421,9 @@ class HiDateRangePicker extends React.Component {
399
421
  // Disable days before 'from' date if define
400
422
 
401
423
  let before;
402
- if (from && disablePastDays) {
424
+ if (from instanceof Date && disablePastDays) {
403
425
  before = from < now ? now : from;
404
- } else if (from) {
426
+ } else if (from instanceof Date) {
405
427
  before = from;
406
428
  } else if (disablePastDays) {
407
429
  before = now;
@@ -431,7 +453,8 @@ class HiDateRangePicker extends React.Component {
431
453
  }, props, labelFrom && {
432
454
  label: labelFrom
433
455
  }, {
434
- id: `${id}-from`
456
+ id: `${id}-from`,
457
+ onChange: this.handleInputChange('from')
435
458
  });
436
459
 
437
460
  const toInputProps = _extends({}, onReset && {
@@ -439,15 +462,13 @@ class HiDateRangePicker extends React.Component {
439
462
  }, props, labelTo && {
440
463
  label: labelTo
441
464
  }, {
442
- id: `${id}-to`
465
+ id: `${id}-to`,
466
+ onChange: this.handleInputChange('to')
443
467
  });
444
468
 
445
- let fromClass = classNames({
446
- [classes.absolute]: staticPosition === true && this.state.focusedInput === 'to',
447
- [classes.dayPickerMargin]: staticPosition === true && this.state.focusedInput === 'to'
448
- });
449
469
  let toClass = classNames(classes.toInput, {
450
- [classes.absolute]: staticPosition === true && this.state.focusedInput === 'from'
470
+ [classes.absolute]: staticPosition === true && this.state.focusedInput === 'from',
471
+ [classes.right4]: staticPosition === true && this.state.focusedInput === 'from'
451
472
  });
452
473
 
453
474
  return React.createElement(
@@ -462,7 +483,7 @@ class HiDateRangePicker extends React.Component {
462
483
  },
463
484
  React.createElement(
464
485
  'div',
465
- { className: fromClass },
486
+ null,
466
487
  React.createElement(DayPickerInput, {
467
488
  ref: el => {
468
489
  this.fromInput = el;
@@ -560,7 +581,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
560
581
  /**
561
582
  * Date de début sélectionnée
562
583
  */
563
- from: PropTypes.instanceOf(Date),
584
+ from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
564
585
  /**
565
586
  * Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
566
587
  */
@@ -596,7 +617,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
596
617
  /**
597
618
  * Date de fin sélectionnée
598
619
  */
599
- to: PropTypes.instanceOf(Date),
620
+ to: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
600
621
  /**
601
622
  * Traductions
602
623
  */
@@ -301,7 +301,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
301
301
  /**
302
302
  * Date de début sélectionnée
303
303
  */
304
- from: PropTypes.instanceOf(Date),
304
+ from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
305
305
  /**
306
306
  * Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
307
307
  */
@@ -349,7 +349,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
349
349
  /**
350
350
  * Date de fin sélectionnée
351
351
  */
352
- to: PropTypes.instanceOf(Date),
352
+ to: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
353
353
  /**
354
354
  * Traductions
355
355
  */
@@ -80,7 +80,7 @@ Overlay.propTypes = process.env.NODE_ENV !== "production" ? {
80
80
  * ReactDayPicker prop
81
81
  * The currently selected day or selected days
82
82
  */
83
- selectedDay: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
83
+ selectedDay: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
84
84
  /**
85
85
  * Définit comment construire le Paper dans le cas d'un double input
86
86
  */
@@ -22,6 +22,9 @@ export default (theme => ({
22
22
  absolute: {
23
23
  position: 'absolute'
24
24
  },
25
+ right4: {
26
+ right: 4
27
+ },
25
28
  dayPickerMargin: {
26
29
  top: -337,
27
30
  width: 'calc(100% - 4px)'
@@ -230,7 +230,8 @@ class HiInput extends React.PureComponent {
230
230
  rows,
231
231
  inputClassName,
232
232
  onReset,
233
- theme
233
+ theme,
234
+ startAdornmentColor
234
235
  } = this.props;
235
236
 
236
237
  const { focused } = this.state;
@@ -251,11 +252,15 @@ class HiInput extends React.PureComponent {
251
252
  });
252
253
 
253
254
  let leftIcon;
255
+ let startAdornmentStyle = { padding: 8 };
256
+ if (startAdornmentColor) {
257
+ startAdornmentStyle.color = startAdornmentColor;
258
+ }
254
259
  if (startAdornment) {
255
260
  leftIcon = React.createElement(HiIconBuilder, {
256
261
  icon: startAdornment,
257
262
  size: 36,
258
- style: { padding: '8px' },
263
+ style: startAdornmentStyle,
259
264
  onClick: this.props.onLeftIconClick,
260
265
  className: classNames(classes.startAdornment, {
261
266
  [classes.startAdornmentFocus]: focused,
@@ -454,6 +459,10 @@ HiInput.propTypes = process.env.NODE_ENV !== "production" ? {
454
459
  * Icône à afficher à gauche de l'input
455
460
  */
456
461
  startAdornment: PropTypes.string,
462
+ /**
463
+ * Couleur de l'icône à afficher à gauche de l'input
464
+ */
465
+ startAdornmentColor: PropTypes.string,
457
466
  /**
458
467
  * @ignore
459
468
  */
@@ -52,7 +52,12 @@ class HiPasswordField extends React.Component {
52
52
  return React.createElement(HiTextField, _extends({}, otherProps, {
53
53
  type: type,
54
54
  onRightIconClick: this.handlePasswordToggle,
55
- HiInputProps: _extends({}, HiInputProps, { endAdornment, placeholder: '', inputClassName })
55
+ HiInputProps: _extends({}, HiInputProps, {
56
+ endAdornment,
57
+ placeholder: '',
58
+ inputClassName,
59
+ autocomplete: 'on'
60
+ })
56
61
  }));
57
62
  }
58
63
  }
@@ -6,14 +6,14 @@ import withStyles from '../styles/withStyles';
6
6
  export const styles = () => ({});
7
7
 
8
8
  function HiLoader(props) {
9
- const { theme, loading } = props;
9
+ const { className, theme, loading, size = 12 } = props;
10
10
 
11
11
  return React.createElement(
12
12
  'div',
13
- { id: 'hi-loader' },
13
+ { id: 'hi-loader', className: className },
14
14
  React.createElement(PropagateLoader, {
15
15
  loading: loading,
16
- size: 12,
16
+ size: size,
17
17
  color: theme.palette.business.primary.normal
18
18
  })
19
19
  );
@@ -206,6 +206,7 @@ class HiSelect extends React.PureComponent {
206
206
  classes,
207
207
  disabled,
208
208
  error,
209
+ loading,
209
210
  options,
210
211
  checkbox,
211
212
  searchable,
@@ -231,8 +232,21 @@ class HiSelect extends React.PureComponent {
231
232
  const selectedIdList = Array.isArray(value) ? value : value ? [value] : [];
232
233
 
233
234
  let _suggestions = [...suggestions];
235
+
234
236
  if (pinnedItem) {
235
- _suggestions = [pinnedItem, ...suggestions];
237
+ _suggestions.unshift(pinnedItem);
238
+ }
239
+
240
+ // If loading
241
+ if (loading) {
242
+ _suggestions.unshift({
243
+ id: '_loading',
244
+ type: 'loader',
245
+ disabled: true,
246
+ centered: true,
247
+ checkbox: false,
248
+ label: 'loading'
249
+ });
236
250
  }
237
251
 
238
252
  if (this.state.dynamic && selectedIdList.length === 1) {
@@ -715,6 +729,10 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
715
729
  * id du select
716
730
  */
717
731
  id: PropTypes.string,
732
+ /**
733
+ * Ajoute un loader
734
+ */
735
+ loading: PropTypes.bool,
718
736
  /**
719
737
  * Autorise la sélection de plusieurs valeurs
720
738
  */
@@ -134,6 +134,7 @@ class HiSuggestSelect extends React.PureComponent {
134
134
  label: showNoResults ? translations.no_result_match : translations.min_length
135
135
  }];
136
136
  }
137
+
137
138
  const open = !!optionsShown.length && focused;
138
139
 
139
140
  return React.createElement(
@@ -196,7 +197,7 @@ HiSuggestSelect.defaultProps = {
196
197
  showMinLength: false,
197
198
  showNoResults: false,
198
199
  translations: {
199
- no_result_match: 'No result match',
200
+ no_result_match: 'Aucun résultat correspondant',
200
201
  min_length: 'Veuillez saisir 3 caractères minimum'
201
202
  },
202
203
  options: []
@@ -10,6 +10,7 @@ import withStyles from '../styles/withStyles';
10
10
  import { escapeHTML } from '../utils/hiHelpers';
11
11
  import HiIconBuilder from '../utils/HiIconBuilder';
12
12
  import HiColoredLabel from '../HiColoredLabel';
13
+ import HiLoader from '../HiLoader';
13
14
 
14
15
  export const styles = theme => ({
15
16
  listItem: {
@@ -35,6 +36,13 @@ export const styles = theme => ({
35
36
  textAlign: 'center',
36
37
  width: '100%'
37
38
  },
39
+ loader: {
40
+ textAlign: 'center',
41
+ width: 1,
42
+ height: 22,
43
+ padding: '8px 0',
44
+ margin: 'auto'
45
+ },
38
46
  selected: {
39
47
  backgroundColor: theme.palette.selected
40
48
  },
@@ -182,6 +190,9 @@ class HiSelectableListItem extends React.Component {
182
190
  { className: itemPrimaryHighlightClass, 'data-id': item.id },
183
191
  this.getItemLabel(item)
184
192
  );
193
+ case 'loader':
194
+ return React.createElement(HiLoader, { loading: true, className: classes.loader, size: 8 });
195
+ break;
185
196
  case 'text':
186
197
  default:
187
198
  const itemTextClass = classNames(classes.listItemContent, {
@@ -31,7 +31,7 @@ CellAccount.propTypes = process.env.NODE_ENV !== "production" ? {
31
31
  /**
32
32
  * Couleur du compte
33
33
  */
34
- color: PropTypes.string.isRequired,
34
+ color: PropTypes.string,
35
35
  /**
36
36
  * Nom du compte
37
37
  */
@@ -68,7 +68,7 @@ CellStatus.propTypes = process.env.NODE_ENV !== "production" ? {
68
68
  /**
69
69
  * Code du statut courant de la transaction (détermine la couleur du label)
70
70
  */
71
- code: PropTypes.number.isRequired,
71
+ code: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
72
72
  /**
73
73
  * Fonction de callback appelée pour ouvrir les lignes de détails
74
74
  */
@@ -73,7 +73,7 @@ export const styles = theme => ({
73
73
  fontSize: 14
74
74
  },
75
75
  button: {
76
- height: 40,
76
+ minHeight: 40,
77
77
  fontSize: 14,
78
78
  width: '50%'
79
79
  },
package/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Material-UI v1.0.0-beta.22
1
+ /** @license Material-UI v1.0.0-beta.23
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.22
1
+ /** @license Material-UI v1.0.0-beta.23
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.22",
5
+ "version": "1.0.0-beta.23",
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": {