@hipay/hipay-material-ui 2.0.0-beta.54 → 2.0.0-beta.56

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/HiBreadcrumb/HiBreadcrumb.js +14 -4
  3. package/HiBreadcrumb/HiStep.js +4 -1
  4. package/HiBreadcrumb/HiStepContent.js +0 -1
  5. package/HiBreadcrumb/HiStepLabel.js +12 -4
  6. package/HiBreadcrumb/HiStepper.js +1 -1
  7. package/HiButton/HiButton.js +7 -1
  8. package/HiCell/CellIcon.js +4 -4
  9. package/HiCell/CellImage.js +28 -4
  10. package/HiCell/CellNumeric.js +1 -2
  11. package/HiCell/CellRate.js +6 -3
  12. package/HiCell/CellSentinel.js +7 -10
  13. package/HiCell/CellSentinelScore.js +4 -4
  14. package/HiCell/CellTextStyled.js +99 -0
  15. package/HiCell/index.js +9 -1
  16. package/HiChip/HiChip.js +1 -0
  17. package/HiDatePicker/Caption.js +8 -9
  18. package/HiDatePicker/HiDateRangePicker.js +37 -19
  19. package/HiDatePicker/HiDateRangeSelector.js +24 -22
  20. package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
  21. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  22. package/HiDatePicker/Overlays/Overlay.js +15 -8
  23. package/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  24. package/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  25. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  26. package/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
  27. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  28. package/HiDatePicker/stylesheet.js +3 -2
  29. package/HiDotsStepper/HiDot.js +108 -0
  30. package/HiDotsStepper/HiDotsStepper.js +121 -0
  31. package/HiExpansionPanel/HiExpansionPanel.js +1 -1
  32. package/HiForm/HiAddressField.js +176 -0
  33. package/HiForm/HiSlider.js +352 -0
  34. package/HiForm/HiUpload.js +204 -0
  35. package/HiForm/HiUploadField.js +182 -0
  36. package/HiForm/HiUploadInput.js +459 -0
  37. package/HiForm/index.js +16 -0
  38. package/HiMap/HiMap.js +345 -0
  39. package/HiMap/HiMapExpand.js +210 -0
  40. package/HiMap/index.js +23 -0
  41. package/HiNotice/HiKPI.js +238 -0
  42. package/HiNotice/HiKPINotice.js +93 -0
  43. package/HiNotice/index.js +23 -0
  44. package/HiPdfReader/HiPdfReader.js +269 -0
  45. package/HiPdfReader/index.js +15 -0
  46. package/HiRadio/HiRadio.js +74 -0
  47. package/HiRadio/index.js +15 -0
  48. package/HiSelect/HiSelect.js +73 -84
  49. package/HiSelect/HiSuggestSelect.js +32 -5
  50. package/HiSelect/SelectInput.js +5 -0
  51. package/HiSelectNew/HiNestedSelectContent.js +5 -1
  52. package/HiSelectNew/HiSelect.js +174 -137
  53. package/HiSelectNew/HiSelectContent.js +0 -8
  54. package/HiSelectNew/HiSelectInput.js +8 -9
  55. package/HiSelectableList/HiSelectableList.js +32 -4
  56. package/HiSelectableList/HiSelectableListItem.js +62 -24
  57. package/HiTable/HiCellBuilder.js +42 -32
  58. package/HiTable/HiTableHeader.js +28 -21
  59. package/HiTable/constants.js +3 -1
  60. package/README.md +249 -98
  61. package/es/HiBreadcrumb/HiBreadcrumb.js +14 -4
  62. package/es/HiBreadcrumb/HiStep.js +4 -1
  63. package/es/HiBreadcrumb/HiStepContent.js +0 -1
  64. package/es/HiBreadcrumb/HiStepLabel.js +13 -4
  65. package/es/HiBreadcrumb/HiStepper.js +1 -1
  66. package/es/HiButton/HiButton.js +7 -0
  67. package/es/HiCell/CellIcon.js +5 -5
  68. package/es/HiCell/CellImage.js +25 -2
  69. package/es/HiCell/CellNumeric.js +1 -2
  70. package/es/HiCell/CellRate.js +6 -3
  71. package/es/HiCell/CellSentinel.js +7 -10
  72. package/es/HiCell/CellSentinelScore.js +4 -4
  73. package/es/HiCell/CellTextStyled.js +84 -0
  74. package/es/HiCell/index.js +2 -1
  75. package/es/HiChip/HiChip.js +1 -0
  76. package/es/HiDatePicker/Caption.js +7 -9
  77. package/es/HiDatePicker/HiDateRangePicker.js +41 -25
  78. package/es/HiDatePicker/HiDateRangeSelector.js +24 -22
  79. package/es/HiDatePicker/ListPicker.js +1 -1
  80. package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
  81. package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +2 -2
  82. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  83. package/es/HiDatePicker/Overlays/Overlay.js +16 -9
  84. package/es/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  85. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  86. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  87. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
  88. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  89. package/es/HiDatePicker/stylesheet.js +3 -2
  90. package/es/HiDotsStepper/HiDot.js +66 -0
  91. package/es/HiDotsStepper/HiDotsStepper.js +73 -0
  92. package/es/HiExpansionPanel/HiExpansionPanel.js +1 -1
  93. package/es/HiForm/HiAddressField.js +134 -0
  94. package/es/HiForm/HiSlider.js +302 -0
  95. package/es/HiForm/HiUpload.js +158 -0
  96. package/es/HiForm/HiUploadField.js +140 -0
  97. package/es/HiForm/HiUploadInput.js +411 -0
  98. package/es/HiForm/index.js +2 -0
  99. package/es/HiMap/HiMap.js +290 -0
  100. package/es/HiMap/HiMapExpand.js +162 -0
  101. package/es/HiMap/index.js +2 -0
  102. package/es/HiNotice/HiKPI.js +196 -0
  103. package/es/HiNotice/HiKPINotice.js +77 -0
  104. package/es/HiNotice/index.js +2 -0
  105. package/es/HiPdfReader/HiPdfReader.js +214 -0
  106. package/es/HiPdfReader/index.js +1 -0
  107. package/es/HiRadio/HiRadio.js +55 -0
  108. package/es/HiRadio/index.js +1 -0
  109. package/es/HiSelect/HiSelect.js +68 -78
  110. package/es/HiSelect/HiSuggestSelect.js +27 -6
  111. package/es/HiSelect/SelectInput.js +5 -0
  112. package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
  113. package/es/HiSelectNew/HiSelect.js +156 -120
  114. package/es/HiSelectNew/HiSelectContent.js +0 -7
  115. package/es/HiSelectNew/HiSelectInput.js +8 -9
  116. package/es/HiSelectableList/HiSelectableList.js +28 -6
  117. package/es/HiSelectableList/HiSelectableListItem.js +71 -24
  118. package/es/HiTable/HiCellBuilder.js +140 -136
  119. package/es/HiTable/HiTableHeader.js +26 -18
  120. package/es/HiTable/constants.js +1 -0
  121. package/es/index.js +7 -0
  122. package/es/utils/helpers.js +1 -1
  123. package/index.es.js +8 -1
  124. package/index.js +57 -1
  125. package/package.json +6 -3
  126. package/umd/hipay-material-ui.development.js +42114 -35120
  127. package/umd/hipay-material-ui.production.min.js +2 -2
  128. package/utils/helpers.js +1 -1
@@ -138,6 +138,105 @@ function (_React$PureComponent) {
138
138
  (0, _classCallCheck2.default)(this, HiSelect);
139
139
  _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiSelect).call(this, props));
140
140
 
141
+ _this.buildSelectProps = function (options) {
142
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
143
+ var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
144
+ var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
145
+ // build item list
146
+ var itemList = (0, _toConsumableArray2.default)(loading ? [{
147
+ id: '_loading',
148
+ type: 'loader',
149
+ disabled: true,
150
+ centered: true,
151
+ hideCheckbox: true,
152
+ label: 'loading'
153
+ }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
154
+ return item.label && (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(search.toLowerCase())) !== -1;
155
+ })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
156
+ id: '_all',
157
+ label: _this.props.translations.all
158
+ }, _this.props.iconAll && {
159
+ type: 'icon',
160
+ icon: _this.props.iconAll
161
+ })] : []).concat((0, _toConsumableArray2.default)(options))));
162
+ return {
163
+ itemList: itemList,
164
+ inputValue: _this.buildInputValue(options, value, loading)
165
+ };
166
+ };
167
+
168
+ _this.buildInputValue = function (options) {
169
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
170
+ var loading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
171
+ var _this$props = _this.props,
172
+ classes = _this$props.classes,
173
+ hasAll = _this$props.hasAll,
174
+ translations = _this$props.translations,
175
+ type = _this$props.type; // build input value
176
+
177
+ var inputValue;
178
+
179
+ if (loading && value.length === 1) {
180
+ inputValue = translations.one_item_selected;
181
+ } else if (hasAll && options.length === value.length) {
182
+ inputValue = translations.all;
183
+ value.unshift('_all');
184
+ } else if (value.length > 1) {
185
+ inputValue = translations.n_items_selected.replace('%s', value.length);
186
+ } else if (value.length === 1) {
187
+ var item = options.find(function (o) {
188
+ return o.id === value[0];
189
+ });
190
+
191
+ if (item === undefined) {
192
+ inputValue = translations.one_item_selected;
193
+ } else if (type === 'icon' || item.type === 'icon') {
194
+ inputValue = _react.default.createElement("span", {
195
+ className: classes.selectIconLabel
196
+ }, _react.default.createElement(_HiIcon.default, {
197
+ className: classes.labelIcon,
198
+ icon: item.icon
199
+ }), item.label);
200
+ } else if (type === 'image' || item.type === 'image') {
201
+ inputValue = _react.default.createElement("span", {
202
+ className: classes.selectIconLabel
203
+ }, _react.default.createElement("img", {
204
+ className: classes.labelImg,
205
+ src: item.img,
206
+ alt: item.label
207
+ }), item.label);
208
+ } else {
209
+ inputValue = item.label;
210
+ }
211
+ }
212
+
213
+ return inputValue;
214
+ };
215
+
216
+ _this.focusOnFirstItem = function () {
217
+ var overlay = (0, _reactDom.findDOMNode)(_this.overlay);
218
+ setTimeout(function () {
219
+ var item = overlay.getElementsByTagName('li')[0];
220
+ item.focus();
221
+ }, 1);
222
+ };
223
+
224
+ _this.getInputElement = function (el) {
225
+ _this.searchField = el;
226
+
227
+ if (_this.props.inputRef) {
228
+ _this.props.inputRef(_this.searchField);
229
+ }
230
+ };
231
+
232
+ _this.handleBlur = function () {
233
+ _this.handleSearchReset();
234
+
235
+ _this.setState({
236
+ focused: false
237
+ });
238
+ };
239
+
141
240
  _this.handleClick = function () {
142
241
  if (_this.state.open) {
143
242
  _this.handleClose();
@@ -151,20 +250,59 @@ function (_React$PureComponent) {
151
250
  if (_this.props.onClick) _this.props.onClick(); // Gestion du focus
152
251
 
153
252
  if (!_this.props.searchable) {
154
- // sinon focus sur le premier élément de la liste
155
- _this.focusOnFirstItem();
253
+ // Sinon focus sur l'élément sélectionné
254
+ _this.focusOnSelectedItem(_this.props.value);
156
255
  }
157
256
  }
158
257
  };
159
258
 
160
- _this.focusOnFirstItem = function () {
259
+ _this.focusOnSelectedItem = function (selectedValue) {
161
260
  var overlay = (0, _reactDom.findDOMNode)(_this.overlay);
162
261
  setTimeout(function () {
262
+ // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
163
263
  var item = overlay.getElementsByTagName('li')[0];
164
- item.focus();
264
+
265
+ if (selectedValue && typeof selectedValue === 'string') {
266
+ item = overlay.getElementsByTagName('li')[selectedValue];
267
+ } else if (selectedValue && typeof selectedValue === 'number') {
268
+ item = overlay.getElementsByTagName('li')[selectedValue - 1];
269
+ }
270
+
271
+ if (item) {
272
+ item.focus();
273
+ }
165
274
  }, 1);
166
275
  };
167
276
 
277
+ _this.handleClickAway = function (event) {
278
+ // Au clic sur le bouton, on laisse le handleClick fermer le select
279
+ if (!_this.inputEl.contains(event.target)) {
280
+ _this.handleClose(event);
281
+ }
282
+ };
283
+
284
+ _this.handleClose = function () {
285
+ _this.handleSearchReset();
286
+
287
+ _this.setState({
288
+ open: false
289
+ });
290
+
291
+ if (_this.props.onClose) {
292
+ _this.props.onClose();
293
+ }
294
+
295
+ if (_this.inputEl) {
296
+ _this.inputEl.focus();
297
+ }
298
+ };
299
+
300
+ _this.handleFocus = function () {
301
+ _this.setState({
302
+ focused: true
303
+ });
304
+ };
305
+
168
306
  _this.handleKeyDown = function (event) {
169
307
  var nextItem;
170
308
  var key = (0, _keycode.default)(event);
@@ -210,46 +348,19 @@ function (_React$PureComponent) {
210
348
  }
211
349
  };
212
350
 
213
- _this.handleFocus = function () {
214
- _this.setState({
215
- focused: true
216
- });
217
- };
218
-
219
- _this.handleBlur = function () {
220
- _this.setState({
221
- focused: false
222
- });
223
- };
224
-
225
- _this.handleClose = function () {
226
- _this.setState({
227
- open: false
228
- });
229
-
230
- if (_this.props.onClose) {
231
- _this.props.onClose();
232
- }
233
-
234
- if (_this.inputEl) {
235
- _this.inputEl.focus();
236
- }
237
- };
238
-
239
- _this.handleClickAway = function (event) {
240
- // Au clic sur le bouton, on laisse le handleClick fermer le select
241
- if (!_this.inputEl.contains(event.target)) {
242
- _this.handleClose(event);
351
+ _this.handleScroll = function (e) {
352
+ if (e.target.scrollHeight - e.target.clientHeight - e.target.scrollTop < 15) {
353
+ _this.props.onScrollReachBottom();
243
354
  }
244
355
  };
245
356
 
246
357
  _this.handleSelect = function (event, item) {
247
- var _this$props = _this.props,
248
- hasAll = _this$props.hasAll,
249
- multiple = _this$props.multiple,
250
- onChange = _this$props.onChange,
251
- options = _this$props.options,
252
- value = _this$props.value;
358
+ var _this$props2 = _this.props,
359
+ hasAll = _this$props2.hasAll,
360
+ multiple = _this$props2.multiple,
361
+ onChange = _this$props2.onChange,
362
+ options = _this$props2.options,
363
+ value = _this$props2.value;
253
364
 
254
365
  if (!multiple) {
255
366
  // single value
@@ -277,10 +388,10 @@ function (_React$PureComponent) {
277
388
  };
278
389
 
279
390
  _this.handleSuggestions = function (suggestions) {
280
- var _this$props2 = _this.props,
281
- hasAll = _this$props2.hasAll,
282
- iconAll = _this$props2.iconAll,
283
- translations = _this$props2.translations;
391
+ var _this$props3 = _this.props,
392
+ hasAll = _this$props3.hasAll,
393
+ iconAll = _this$props3.iconAll,
394
+ translations = _this$props3.translations;
284
395
 
285
396
  if (suggestions.length === 0) {
286
397
  // Add '_no_result' suggestion
@@ -309,12 +420,6 @@ function (_React$PureComponent) {
309
420
  }
310
421
  };
311
422
 
312
- _this.handleScroll = function (e) {
313
- if (e.target.scrollHeight - e.target.clientHeight - e.target.scrollTop < 15) {
314
- _this.props.onScrollReachBottom();
315
- }
316
- };
317
-
318
423
  _this.handleSearch = function (e, inputValue) {
319
424
  var searchValue = inputValue && e.target.value ? inputValue : e.target.value;
320
425
 
@@ -335,81 +440,6 @@ function (_React$PureComponent) {
335
440
  }, '');
336
441
  };
337
442
 
338
- _this.buildSelectProps = function (options) {
339
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
340
- var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
341
- var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
342
- // build item list
343
- var itemList = (0, _toConsumableArray2.default)(loading ? [{
344
- id: '_loading',
345
- type: 'loader',
346
- disabled: true,
347
- centered: true,
348
- hideCheckbox: true,
349
- label: 'loading'
350
- }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
351
- return item.label && (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(search.toLowerCase())) !== -1;
352
- })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
353
- id: '_all',
354
- label: _this.props.translations.all
355
- }, _this.props.iconAll && {
356
- type: 'icon',
357
- icon: _this.props.iconAll
358
- })] : []).concat((0, _toConsumableArray2.default)(options))));
359
- return {
360
- itemList: itemList,
361
- inputValue: _this.buildInputValue(options, value, loading)
362
- };
363
- };
364
-
365
- _this.buildInputValue = function (options) {
366
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
367
- var loading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
368
- var _this$props3 = _this.props,
369
- classes = _this$props3.classes,
370
- hasAll = _this$props3.hasAll,
371
- translations = _this$props3.translations,
372
- type = _this$props3.type; // build input value
373
-
374
- var inputValue;
375
-
376
- if (loading && value.length === 1) {
377
- inputValue = translations.one_item_selected;
378
- } else if (hasAll && options.length === value.length) {
379
- inputValue = translations.all;
380
- value.unshift('_all');
381
- } else if (value.length > 1) {
382
- inputValue = translations.n_items_selected.replace('%s', value.length);
383
- } else if (value.length === 1) {
384
- var item = options.find(function (o) {
385
- return o.id === value[0];
386
- });
387
-
388
- if (item === undefined) {
389
- inputValue = translations.one_item_selected;
390
- } else if (type === 'icon' || item.type === 'icon') {
391
- inputValue = _react.default.createElement("span", {
392
- className: classes.selectIconLabel
393
- }, _react.default.createElement(_HiIcon.default, {
394
- className: classes.labelIcon,
395
- icon: item.icon
396
- }), item.label);
397
- } else if (type === 'image' || item.type === 'image') {
398
- inputValue = _react.default.createElement("span", {
399
- className: classes.selectIconLabel
400
- }, _react.default.createElement("img", {
401
- className: classes.labelImg,
402
- src: item.img,
403
- alt: item.label
404
- }), item.label);
405
- } else {
406
- inputValue = item.label;
407
- }
408
- }
409
-
410
- return inputValue;
411
- };
412
-
413
443
  _this.state = {
414
444
  open: false,
415
445
  focused: false,
@@ -430,15 +460,6 @@ function (_React$PureComponent) {
430
460
  }
431
461
 
432
462
  (0, _createClass2.default)(HiSelect, [{
433
- key: "getInputElement",
434
- value: function getInputElement(el) {
435
- this.searchField = el;
436
-
437
- if (this.props.inputRef) {
438
- this.props.inputRef(this.searchField);
439
- }
440
- }
441
- }, {
442
463
  key: "render",
443
464
  value: function render() {
444
465
  var _classNames,
@@ -456,6 +477,7 @@ function (_React$PureComponent) {
456
477
  value = _this$props4.value,
457
478
  multiple = _this$props4.multiple,
458
479
  translations = _this$props4.translations,
480
+ hiSearchInputProps = _this$props4.hiSearchInputProps,
459
481
  hiSelectableListProps = _this$props4.hiSelectableListProps,
460
482
  hiSelectInputProps = _this$props4.hiSelectInputProps,
461
483
  id = _this$props4.id,
@@ -513,7 +535,7 @@ function (_React$PureComponent) {
513
535
  }
514
536
  }, _react.default.createElement(_Paper.default, {
515
537
  className: classes.paper
516
- }, !!searchable && _react.default.createElement(_HiInput.default, {
538
+ }, !!searchable && _react.default.createElement(_HiInput.default, (0, _extends2.default)({
517
539
  value: searchValue,
518
540
  autoFocus: true,
519
541
  inputRef: this.getInputElement,
@@ -523,7 +545,7 @@ function (_React$PureComponent) {
523
545
  placeholder: translations.search,
524
546
  startAdornment: 'search',
525
547
  tabIndex: 0
526
- }), startAdornment, _react.default.createElement(_reactCustomScrollbars.default, (0, _extends2.default)({
548
+ }, hiSearchInputProps)), startAdornment, _react.default.createElement(_reactCustomScrollbars.default, (0, _extends2.default)({
527
549
  ref: function ref(contentEl) {
528
550
  _this2.optionsContent = contentEl;
529
551
  },
@@ -590,6 +612,15 @@ function (_React$PureComponent) {
590
612
 
591
613
  return null;
592
614
  }
615
+ /**
616
+ * Build itemList & inputValue from select props
617
+ * @param options
618
+ * @param value
619
+ * @param search
620
+ * @param loading
621
+ * @returns {{itemList: *[], inputValue: *}}
622
+ */
623
+
593
624
  }]);
594
625
  return HiSelect;
595
626
  }(_react.default.PureComponent);
@@ -602,6 +633,7 @@ HiSelect.defaultProps = {
602
633
  hasAll: false,
603
634
  hiSelectableListProps: {},
604
635
  hiSelectInputProps: {},
636
+ hiSearchInputProps: {},
605
637
  multiple: false,
606
638
  placeholder: '',
607
639
  searchable: false,
@@ -656,7 +688,12 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
656
688
  hasAll: _propTypes.default.bool,
657
689
 
658
690
  /**
659
- * Override HiSelectableList props (
691
+ * Override HiInput props (for search)
692
+ */
693
+ hiSearchInputProps: _propTypes.default.object,
694
+
695
+ /**
696
+ * Override HiSelectableList props
660
697
  */
661
698
  hiSelectableListProps: _propTypes.default.object,
662
699
 
@@ -37,8 +37,6 @@ var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
37
37
 
38
38
  var _helpers = require("../utils/helpers");
39
39
 
40
- var _HiIcon = _interopRequireDefault(require("../HiIcon"));
41
-
42
40
  var _keycode = _interopRequireDefault(require("keycode"));
43
41
 
44
42
  var styles = function styles(theme) {
@@ -295,9 +293,6 @@ function (_React$PureComponent) {
295
293
  var _this2 = this;
296
294
 
297
295
  var _this$props3 = this.props,
298
- classes = _this$props3.classes,
299
- disabled = _this$props3.disabled,
300
- error = _this$props3.error,
301
296
  loading = _this$props3.loading,
302
297
  options = _this$props3.options,
303
298
  searchable = _this$props3.searchable,
@@ -306,10 +301,7 @@ function (_React$PureComponent) {
306
301
  multiple = _this$props3.multiple,
307
302
  translations = _this$props3.translations,
308
303
  hiSelectableListProps = _this$props3.hiSelectableListProps,
309
- hiSelectInputProps = _this$props3.hiSelectInputProps,
310
- id = _this$props3.id,
311
304
  onScrollReachBottom = _this$props3.onScrollReachBottom,
312
- onSubmit = _this$props3.onSubmit,
313
305
  startAdornment = _this$props3.startAdornment,
314
306
  _this$props3$searchVa = _this$props3.searchValue,
315
307
  searchValue = _this$props3$searchVa === void 0 ? this.state.searchValue : _this$props3$searchVa,
@@ -209,14 +209,12 @@ function (_React$PureComponent) {
209
209
  _this.handleBlur = function (event) {
210
210
  if ((!_this.input || !_this.input.contains(event.relatedTarget)) && _this.props.onBlur) {
211
211
  _this.props.onBlur(event);
212
- } else {
213
- if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
214
- _this.input.focus();
215
- }
212
+ } else if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
213
+ _this.input.focus();
216
214
  }
217
215
  };
218
216
 
219
- _this.handleRef = function (el) {
217
+ _this.ref = function (el) {
220
218
  _this.input = el;
221
219
 
222
220
  if (_this.props.refElement) {
@@ -227,7 +225,7 @@ function (_React$PureComponent) {
227
225
  _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
228
226
  _this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
229
227
  _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
230
- _this.handleRef = _this.handleRef.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
228
+ _this.ref = _this.ref.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
231
229
  _this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
232
230
  return _this;
233
231
  }
@@ -265,7 +263,7 @@ function (_React$PureComponent) {
265
263
  onBlur: this.props.onBlur,
266
264
  role: "button",
267
265
  tabIndex: "0",
268
- ref: this.handleRef
266
+ ref: this.ref
269
267
  }, _react.default.createElement("span", {
270
268
  className: (0, _classnames.default)(classes.label, (0, _defineProperty2.default)({}, classes.placeholder, value === undefined))
271
269
  }, value || placeholder), _react.default.createElement(_ArrowDropDown.default, {
@@ -279,8 +277,9 @@ function (_React$PureComponent) {
279
277
  onMouseLeave: this.props.onMouseLeave,
280
278
  onKeyDown: this.handleKeyDown,
281
279
  onFocus: this.props.onFocus,
282
- onBlur: this.handleBlur,
283
- buttonRef: this.handleRef
280
+ onBlur: this.handleBlur // buttref={this.ref}
281
+ ,
282
+ buttonRef: this.ref
284
283
  }, _react.default.createElement("span", {
285
284
  className: (0, _classnames.default)(classes.label, (0, _defineProperty2.default)({}, classes.placeholder, value === undefined))
286
285
  }, value || placeholder), onReset && focused && _react.default.createElement("div", {
@@ -33,6 +33,8 @@ var _HiSelectableListItem = _interopRequireDefault(require("./HiSelectableListIt
33
33
 
34
34
  var _helpers = require("../utils/helpers");
35
35
 
36
+ var _keycode = _interopRequireDefault(require("keycode"));
37
+
36
38
  var styles = function styles() {
37
39
  return {
38
40
  root: {
@@ -71,6 +73,31 @@ function (_React$PureComponent) {
71
73
  };
72
74
  };
73
75
 
76
+ _this.handleKeyDown = function (event) {
77
+ var nextItem;
78
+ var key = (0, _keycode.default)(event);
79
+
80
+ if (key === 'down') {
81
+ event.preventDefault();
82
+ nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'down');
83
+ } else if (key === 'up') {
84
+ event.preventDefault();
85
+ nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'up');
86
+ } else if (key === 'space' || key === 'enter' && !_this.props.multiple) {
87
+ event.preventDefault();
88
+
89
+ var item = _this.props.options.find(function (elem) {
90
+ return String(elem.id) === event.target.id;
91
+ });
92
+
93
+ _this.handleSelect(null, item);
94
+ }
95
+
96
+ if (nextItem) {
97
+ nextItem.focus();
98
+ }
99
+ };
100
+
74
101
  _this.buildRecursiveListItem = function (item) {
75
102
  var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
76
103
  var _this$props = _this.props,
@@ -82,7 +109,9 @@ function (_React$PureComponent) {
82
109
  icon = _this$props.icon,
83
110
  selectedItemIdList = _this$props.selectedItemIdList,
84
111
  sort = _this$props.sort,
85
- others = (0, _objectWithoutProperties2.default)(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "selectedItemIdList", "sort"]);
112
+ _this$props$onKeyDown = _this$props.onKeyDown,
113
+ onKeyDown = _this$props$onKeyDown === void 0 ? _this.handleKeyDown : _this$props$onKeyDown,
114
+ others = (0, _objectWithoutProperties2.default)(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "selectedItemIdList", "sort", "onKeyDown"]);
86
115
 
87
116
  if (sort && item.children) {
88
117
  item.children.sort(_this.compareItem);
@@ -98,6 +127,7 @@ function (_React$PureComponent) {
98
127
  icon: icon,
99
128
  level: level,
100
129
  onSelect: _this.handleSelect(item),
130
+ onKeyDown: onKeyDown,
101
131
  selected: selectedItemIdList.includes(item.id) // item props override upper props (disabled, hideCheckbox, icon, level...)
102
132
 
103
133
  }, item)), item.children && item.children.length > 0 && item.children.filter(function (subItem) {
@@ -136,7 +166,6 @@ function (_React$PureComponent) {
136
166
  var _this$props2 = this.props,
137
167
  classes = _this$props2.classes,
138
168
  itemList = _this$props2.itemList,
139
- onKeyDown = _this$props2.onKeyDown,
140
169
  sort = _this$props2.sort;
141
170
 
142
171
  if (sort) {
@@ -144,8 +173,7 @@ function (_React$PureComponent) {
144
173
  }
145
174
 
146
175
  return _react.default.createElement(_List.default, {
147
- className: classes.root,
148
- onKeyDown: onKeyDown
176
+ className: classes.root
149
177
  }, itemList.filter(function (item) {
150
178
  return !(item.displayed === false);
151
179
  }) // don't remove if undefined