@hipay/hipay-material-ui 2.0.0-beta.57 → 2.0.0-beta.58

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,61 @@
1
+ # [2.0.0-beta.58](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.58) (2018-12-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **eslint:** remove eslint warrnings in components (ignore test files) ([d236c62](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d236c62))
7
+ * **HiBreadcrumb:** clean eslint warnings ([6db12fb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6db12fb))
8
+ * **HiDatePicker:** add static positions for custom overlays ([c3edf24](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c3edf24))
9
+ * **HiExpansionPanel:** Fix props type a requirement ([cbc3b48](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cbc3b48))
10
+ * **HiInput:** handle focus state through prop when needed to override default comportment ([9a133cc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9a133cc))
11
+ * **HiKpiNotice:** eslint clean warnings ([11b5552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/11b5552))
12
+ * **HiSelect:** Fix build of HiSelectContent ([4b87f78](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4b87f78))
13
+ * **HiSelect:** focus on undefined item ([2d084e6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2d084e6))
14
+ * **HiSelect:** handle staticPosition & width properly for HiDateRangeSelector usage ([7b19ffb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7b19ffb))
15
+ * **HiSelectableListItem:** disabled item checkbox color ([9f10552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9f10552))
16
+ * **HiSelectableListItem:** remove item width ([a913945](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a913945))
17
+ * **HiSelectContent:** Remove compute of input value ([b86db83](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b86db83))
18
+ * **HiSlider:** eslint clean warnings ([08964b1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/08964b1))
19
+ * **HiUploadField:** clean eslint warnings ([c76aaf1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c76aaf1))
20
+ * **migration:** fix contrast threshold ... ([6fb3b18](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6fb3b18))
21
+ * **package:** add cross-env ([7098fd6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7098fd6))
22
+
23
+
24
+ ### Features
25
+
26
+ * **CellImage:** Handle fallbackImage ([254799d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/254799d))
27
+ * **CellSentinel:** Uniformize cell api with front CellSentinel ([4e2975b](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4e2975b))
28
+ * **CellSentinel:** Update CellSentinel to the new way (split each result in different column) ([efe2711](https://gitlab.hipay.org/backend/hipay-material-ui/commit/efe2711))
29
+ * **CellSentinelScore:** Add CellSentinelScore ([2fff04d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2fff04d))
30
+ * **CellText:** Handle active prop in CellText & column views in HiTable ([4366e60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4366e60))
31
+ * **HiCells:** Add simple cells types (Address, Date, Icon, Image, Numeric, PinToAction, Rate, Senti ([f688517](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f688517))
32
+ * **HiDatePicker:** BREAKING CHANGE - add local prop to handle calendar translations ([b1b3743](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1b3743))
33
+ * **HiIcon:** Add mdi-material-ui as available icons via 'mdi_' prefix ([1091d6d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/1091d6d))
34
+ * **HiMap:** unregister fetch on unmount ([0afa931](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0afa931))
35
+ * **HiSelect:** Add (NEW) HiSelect, HiNestedSelect, HiDynamicSelect ([4c6447e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4c6447e))
36
+ * **HiSelect:** Reset search input on blur & on close ([d9af584](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d9af584))
37
+ * **HiSelectableList:** Add sort props to sort item list on label ([f412ddc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f412ddc))
38
+ * **HiSelectContent:** Add new HiSelectContent & HiNestedSelectContent ([215ad8f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/215ad8f))
39
+ * **HiSelectContent:** export utils functions ([7c41d87](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7c41d87))
40
+ * **HiUploadField:** rename component HiUploadField ([593f77e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/593f77e))
41
+ * **notice:** Création notice KPI ([bba3f89](https://gitlab.hipay.org/backend/hipay-material-ui/commit/bba3f89))
42
+
43
+
44
+ ### Performance Improvements
45
+
46
+ * **PureFunction:** Use pure & functional components ([220c686](https://gitlab.hipay.org/backend/hipay-material-ui/commit/220c686))
47
+
48
+
49
+ ### BREAKING CHANGES
50
+
51
+ * **HiDatePicker:** Required "local" props (use polyglot, p.currentLocal)
52
+ * **HiUploadField:** Components names changes
53
+ * **HiCells:** Remove CellCountry, CellThirdParty, CellStatus & CellAccount (use generic type
54
+ CellImage & CellText)
55
+ * **HiSelect:** HiSelect API change, use HiNestedSelect or HiDynamicSelect relative to situation
56
+
57
+
58
+
1
59
  <a name="2.0.0-beta.41"></a>
2
60
  # [2.0.0-beta.41](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.41) (2018-12-07)
3
61
 
@@ -41,20 +41,28 @@ var _styles = require("../styles");
41
41
 
42
42
  var _HiButton = _interopRequireDefault(require("../HiButton"));
43
43
 
44
+ var _HiIcon = _interopRequireDefault(require("../HiIcon"));
45
+
44
46
  // @inheritedComponent Dialog
45
47
  var styles = function styles(theme) {
46
48
  return {
47
49
  classContent: {
48
50
  fontSize: 14,
49
- lineHeight: '24px',
50
- color: '#484848'
51
+ lineHeight: '20px',
52
+ color: '#484848',
53
+ position: 'relative'
51
54
  },
52
- classPaper: {
53
- maxWidth: 300
55
+ classDialogPaper: {
56
+ minHeight: 280,
57
+ maxWidth: 280,
58
+ borderRadius: 2
54
59
  },
55
60
  classCancelButton: {
56
61
  float: 'right'
57
62
  },
63
+ classSubmitButton: {
64
+ margin: '0'
65
+ },
58
66
  classTitle: {
59
67
  fontSize: 20,
60
68
  fontFamily: theme.typography.fontFamily,
@@ -62,10 +70,20 @@ var styles = function styles(theme) {
62
70
  lineHeight: '24px'
63
71
  },
64
72
  classAction: {
65
- display: 'inline-block'
73
+ display: 'inline-block',
74
+ margin: '0',
75
+ padding: '0px 24px 24px 24px'
66
76
  },
67
77
  classDialogRoot: {
68
78
  backgroundColor: 'rgba(0, 0, 0, 0.28)'
79
+ },
80
+ classBackgroundIcon: {
81
+ position: 'absolute',
82
+ top: 'calc(50%)',
83
+ left: '50%',
84
+ transform: 'translate(-50%, -50%)',
85
+ color: theme.palette.background2,
86
+ flex: '1'
69
87
  }
70
88
  };
71
89
  };
@@ -117,6 +135,8 @@ function (_React$PureComponent) {
117
135
  // Render
118
136
  value: function render() {
119
137
  var _this$props = this.props,
138
+ backgroundIcon = _this$props.backgroundIcon,
139
+ iconSize = _this$props.iconSize,
120
140
  classes = _this$props.classes,
121
141
  content = _this$props.content,
122
142
  labelCancelButton = _this$props.labelCancelButton,
@@ -124,17 +144,23 @@ function (_React$PureComponent) {
124
144
  onCancelClick = _this$props.onCancelClick,
125
145
  onSubmitClick = _this$props.onSubmitClick,
126
146
  open = _this$props.open,
147
+ cancelColor = _this$props.cancelColor,
127
148
  submitColor = _this$props.submitColor,
128
149
  title = _this$props.title,
129
- props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "content", "labelCancelButton", "labelSubmitButton", "onCancelClick", "onSubmitClick", "open", "submitColor", "title"]);
150
+ props = (0, _objectWithoutProperties2.default)(_this$props, ["backgroundIcon", "iconSize", "classes", "content", "labelCancelButton", "labelSubmitButton", "onCancelClick", "onSubmitClick", "open", "cancelColor", "submitColor", "title"]);
130
151
  return _react.default.createElement(_Dialog.default, (0, _extends2.default)({
131
152
  open: open,
132
153
  onClose: this.handleOnClose,
133
154
  classes: {
134
- paper: classes.classPaper,
135
- root: classes.classDialogRoot
155
+ root: classes.classDialogRoot,
156
+ paper: classes.classDialogPaper
136
157
  }
137
- }, props), _react.default.createElement(_DialogTitle.default, {
158
+ }, props), backgroundIcon && _react.default.createElement("div", {
159
+ className: classes.classBackgroundIcon
160
+ }, _react.default.createElement(_HiIcon.default, {
161
+ icon: backgroundIcon,
162
+ size: iconSize
163
+ })), _react.default.createElement(_DialogTitle.default, {
138
164
  disableTypography: true,
139
165
  classes: {
140
166
  root: classes.classTitle
@@ -147,22 +173,39 @@ function (_React$PureComponent) {
147
173
  classes: {
148
174
  root: classes.classAction
149
175
  }
150
- }, _react.default.createElement(_HiButton.default, {
176
+ }, labelSubmitButton && _react.default.createElement(_HiButton.default, {
177
+ classes: {
178
+ root: classes.classSubmitButton
179
+ },
151
180
  onClick: this.handleClickSubmit,
152
181
  color: submitColor
153
- }, labelSubmitButton), _react.default.createElement(_HiButton.default, {
182
+ }, labelSubmitButton), labelCancelButton && _react.default.createElement(_HiButton.default, {
154
183
  classes: {
155
184
  root: classes.classCancelButton
156
185
  },
157
186
  onClick: this.handleClickCancel,
158
- color: "neutral"
187
+ color: cancelColor
159
188
  }, labelCancelButton)));
160
189
  }
161
190
  }]);
162
191
  return HiAlertModal;
163
192
  }(_react.default.PureComponent);
164
193
 
194
+ HiAlertModal.defaultProps = {
195
+ cancelColor: 'neutral',
196
+ submitColor: 'primary'
197
+ };
165
198
  HiAlertModal.propTypes = process.env.NODE_ENV !== "production" ? {
199
+ /**
200
+ * Icon à mettre en fond
201
+ */
202
+ backgroundIcon: _propTypes.default.string,
203
+
204
+ /**
205
+ * The color of the cancel button. It supports those theme colors that make sense for this component.
206
+ */
207
+ cancelColor: _propTypes.default.oneOf(['default', 'inherit', 'primary', 'secondary', 'positive', 'negative', 'middle', 'neutral']),
208
+
166
209
  /**
167
210
  * Surcharge les classes du composant
168
211
  */
@@ -171,7 +214,7 @@ HiAlertModal.propTypes = process.env.NODE_ENV !== "production" ? {
171
214
  /**
172
215
  * Texte contenu dans la modal
173
216
  */
174
- content: _propTypes.default.string,
217
+ content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.node]),
175
218
 
176
219
  /**
177
220
  * Texte sur le bouton d'annulation
@@ -252,14 +252,12 @@ function (_React$PureComponent) {
252
252
  focused: !disabled && (focused || hovered)
253
253
  }, InputLabelProps), error && errorText && _react.default.createElement(_HiIconButton.default, {
254
254
  className: (0, _classnames.default)(classes.iconButton, classes.iconButtonError),
255
- onClick: this.handleHelperClick,
256
- onKeyDown: this.handleKeyDown
255
+ onClick: this.handleHelperClick
257
256
  }, _react.default.createElement(_Warning.default, {
258
257
  className: (0, _classnames.default)(classes.icon)
259
258
  })), helperIcon && helperText && !error && _react.default.createElement(_HiIconButton.default, {
260
259
  className: (0, _classnames.default)(classes.iconButton, classes.iconButtonInfo, (0, _defineProperty2.default)({}, classes.iconButtonInfoActive, helperOpen)),
261
- onClick: this.handleHelperClick,
262
- onKeyDown: this.handleKeyDown
260
+ onClick: this.handleHelperClick
263
261
  }, _react.default.createElement(_Info.default, {
264
262
  className: (0, _classnames.default)(classes.icon)
265
263
  }))), _react.default.createElement("div", {
package/HiForm/HiInput.js CHANGED
@@ -215,10 +215,15 @@ function (_React$PureComponent) {
215
215
  // Si on click sur un élément de HiInput, on garde le focus
216
216
  // Par exemple sur l'icone reset
217
217
  if (event.relatedTarget && this.overlayNode && this.overlayNode.contains(event.relatedTarget)) {
218
- if (this.endAdornmentNode.contains(event.relatedTarget) && this.props.onBlur) {
218
+ // If blur came from erase icon => stay focused and don't call onBlur props
219
+ if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
220
+ event.preventDefault();
221
+ event.stopPropagation();
222
+ } else if (this.endAdornmentNode.contains(event.relatedTarget) && this.props.onBlur) {
219
223
  this.props.onBlur(event);
220
224
  }
221
225
 
226
+ event.preventDefault();
222
227
  event.stopPropagation();
223
228
  } else {
224
229
  this.setState({
@@ -240,9 +245,13 @@ function (_React$PureComponent) {
240
245
  this.setState({
241
246
  focused: true
242
247
  });
243
- }
248
+ } // If focus came from erase icon => stay focused and don't call onFocus props
249
+
244
250
 
245
- if (this.props.onFocus) {
251
+ if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
252
+ event.preventDefault();
253
+ event.stopPropagation();
254
+ } else if (this.props.onFocus) {
246
255
  this.props.onFocus(event);
247
256
  }
248
257
  }
@@ -342,7 +351,10 @@ function (_React$PureComponent) {
342
351
  label: classes.eraseButtonLabel
343
352
  },
344
353
  onClick: this.handleReset,
345
- onBlur: this.handleBlur
354
+ onBlur: this.handleBlur,
355
+ buttonRef: function buttonRef(el) {
356
+ _this2.eraseIconNode = el;
357
+ }
346
358
  }, _ref);
347
359
 
348
360
  var endAdornment = endAdornmentProps;
@@ -49,7 +49,8 @@ var styles = function styles(theme) {
49
49
  fontSize: '80px'
50
50
  },
51
51
  inputContainer: {
52
- flex: '1'
52
+ flex: '1',
53
+ width: 'calc(100% - 88px)'
53
54
  },
54
55
  empty: {
55
56
  border: "1px solid ".concat(theme.palette.input.bottomLine),
@@ -249,17 +249,13 @@ function (_React$PureComponent) {
249
249
  nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'down');
250
250
  } else if (event.key === 'ArrowUp') {
251
251
  nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'up');
252
- } else if (event.key === 'Tab') {
252
+ } else if (event.key === 'Tab' || event.key === 'Escape') {
253
253
  /* if (!this.props.staticPosition) {
254
254
  document.body.style.overflow = 'auto';
255
255
  } */
256
256
  _this.setState({
257
257
  open: false
258
258
  });
259
- } else if (event.key === 'Escape') {
260
- _this.setState({
261
- open: false
262
- });
263
259
  }
264
260
 
265
261
  if (nextItem) {
@@ -272,6 +268,10 @@ function (_React$PureComponent) {
272
268
  _this.focusOnSelectedItem();
273
269
  } else if (event.key === 'Enter' && _this.props.onSubmit) {
274
270
  _this.props.onSubmit(event);
271
+ } else if (event.key === 'Tab' || event.key === 'Escape') {
272
+ _this.setState({
273
+ open: false
274
+ });
275
275
  }
276
276
  };
277
277
 
@@ -750,6 +750,7 @@ function (_React$PureComponent) {
750
750
  onClick: this.handleClick,
751
751
  onFocus: this.handleFocus,
752
752
  onBlur: this.handleBlur,
753
+ onKeyDown: this.handleKeyDown,
753
754
  onMouseEnter: this.props.onMouseEnter,
754
755
  onMouseLeave: this.props.onMouseLeave,
755
756
  refElement: function refElement(el) {
@@ -62,7 +62,8 @@ var styles = function styles(theme) {
62
62
  width: '100% !important',
63
63
  transform: 'none !important',
64
64
  zIndex: '9 !important',
65
- top: '100% !important'
65
+ top: '100% !important',
66
+ textOverflow: 'ellipsis'
66
67
  },
67
68
  paper: {
68
69
  borderRadius: '0px 2px',
@@ -229,6 +229,7 @@ function (_React$PureComponent) {
229
229
  className: iconClass,
230
230
  icon: "arrow_drop_down"
231
231
  })) : _react.default.createElement(_ButtonBase.default, {
232
+ component: "div",
232
233
  id: id,
233
234
  classes: {
234
235
  root: rootClass
@@ -37,8 +37,6 @@ var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
37
37
 
38
38
  var _Popper = _interopRequireDefault(require("@material-ui/core/Popper"));
39
39
 
40
- var _reactDom = require("react-dom");
41
-
42
40
  var _ClickAwayListener = _interopRequireDefault(require("@material-ui/core/ClickAwayListener"));
43
41
 
44
42
  var _HiSelectableList = _interopRequireDefault(require("../HiSelectableList"));
@@ -224,11 +222,13 @@ function (_React$PureComponent) {
224
222
  };
225
223
 
226
224
  _this.focusOnFirstItem = function () {
227
- var overlay = (0, _reactDom.findDOMNode)(_this.overlay);
228
- setTimeout(function () {
229
- var item = overlay.getElementsByTagName('li')[0];
230
- item.focus();
231
- }, 1);
225
+ if (_this.overlay && _this.overlay.getElementsByTagName('li')[0]) {
226
+ setTimeout(function () {
227
+ var item = _this.overlay.getElementsByTagName('li')[0];
228
+
229
+ item.focus();
230
+ }, 1);
231
+ }
232
232
  };
233
233
 
234
234
  _this.getInputElement = function (el) {
@@ -267,15 +267,14 @@ function (_React$PureComponent) {
267
267
  };
268
268
 
269
269
  _this.focusOnSelectedItem = function (selectedValue) {
270
- var overlay = (0, _reactDom.findDOMNode)(_this.overlay);
271
270
  setTimeout(function () {
272
271
  // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
273
- var item = overlay.getElementsByTagName('li')[0];
272
+ var item = _this.overlay.getElementsByTagName('li')[0];
274
273
 
275
274
  if (selectedValue && typeof selectedValue === 'string') {
276
- item = overlay.getElementsByTagName('li')[selectedValue];
275
+ item = _this.overlay.getElementsByTagName('li')[selectedValue];
277
276
  } else if (selectedValue && typeof selectedValue === 'number') {
278
- item = overlay.getElementsByTagName('li')[selectedValue - 1];
277
+ item = _this.overlay.getElementsByTagName('li')[selectedValue - 1];
279
278
  }
280
279
 
281
280
  if (item) {
@@ -313,6 +312,18 @@ function (_React$PureComponent) {
313
312
  });
314
313
  };
315
314
 
315
+ _this.handleKeyDownInput = function (event) {
316
+ var key = (0, _keycode.default)(event);
317
+
318
+ if (key === 'down' || key === 'up') {
319
+ _this.handleClick();
320
+ } else if (key === 'enter' && _this.props.onSubmit) {
321
+ event.preventDefault();
322
+
323
+ _this.props.onSubmit(event);
324
+ }
325
+ };
326
+
316
327
  _this.handleKeyDown = function (event) {
317
328
  var nextItem;
318
329
  var key = (0, _keycode.default)(event);
@@ -323,6 +334,13 @@ function (_React$PureComponent) {
323
334
  } else if (key === 'up') {
324
335
  event.preventDefault();
325
336
  nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'up');
337
+ } else if (key === 'tab' || key === 'esc') {
338
+ _this.setState({
339
+ open: false
340
+ });
341
+ } else if (key === 'space') {
342
+ // Cancel scroll
343
+ event.preventDefault();
326
344
  }
327
345
 
328
346
  if (nextItem) {
@@ -330,21 +348,58 @@ function (_React$PureComponent) {
330
348
  }
331
349
  };
332
350
 
351
+ _this.getItemById = function (id) {
352
+ var item;
353
+
354
+ if (_this.props.hasAll && String(id) === '_all') {
355
+ return {
356
+ id: '_all'
357
+ };
358
+ }
359
+
360
+ for (var i = 0; i < _this.props.options.length; i += 1) {
361
+ var elem = _this.props.options[i];
362
+
363
+ if (String(elem.id) === String(id)) {
364
+ item = elem;
365
+ break;
366
+ }
367
+
368
+ if (elem.children) {
369
+ for (var j = 0; j < elem.children.length; j += 1) {
370
+ if (String(elem.children[j].id) === String(id)) {
371
+ item = elem.children[j];
372
+ break;
373
+ }
374
+ }
375
+ }
376
+ }
377
+
378
+ return item;
379
+ };
380
+
333
381
  _this.handleKeyUp = function (event) {
334
382
  var key = (0, _keycode.default)(event);
335
383
 
336
- if (key === 'tab' || key === 'esc') {
384
+ if (key === 'esc') {
337
385
  _this.setState({
338
386
  open: false
339
387
  });
340
388
  } else if (key === 'space' || key === 'enter' && !_this.props.multiple) {
341
389
  event.preventDefault();
342
390
 
343
- var item = _this.props.options.find(function (elem) {
344
- return String(elem.id) === event.target.id;
345
- });
391
+ var item = _this.getItemById(event.target.id);
346
392
 
347
- _this.handleSelect(null, item);
393
+ if (item) {
394
+ // Select for nested select
395
+ if (_this.props.hiSelectableListProps && _this.props.hiSelectableListProps.onSelect) {
396
+ _this.props.hiSelectableListProps.onSelect(null, item);
397
+ } else {
398
+ _this.handleSelect(null, item);
399
+ }
400
+ } else {
401
+ console.warn("Can not find item #".concat(event.target.id));
402
+ }
348
403
  } else if (key === 'enter' && _this.props.multiple) {
349
404
  event.preventDefault();
350
405
 
@@ -361,6 +416,10 @@ function (_React$PureComponent) {
361
416
  event.preventDefault();
362
417
 
363
418
  _this.handleClose();
419
+ } else if (key === 'tab') {
420
+ _this.setState({
421
+ open: false
422
+ });
364
423
  }
365
424
  };
366
425
 
@@ -543,7 +602,7 @@ function (_React$PureComponent) {
543
602
  var popperClass = (0, _classnames.default)(classes.popper, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.popperWidth, !this.props.containerWidth), (0, _defineProperty2.default)(_classNames, classes.popperRightAlign, this.props.containerWidth && this.props.align === 'right'), _classNames));
544
603
 
545
604
  var searchInput = function searchInput(position) {
546
- if (!!searchable) {
605
+ if (searchable) {
547
606
  return _react.default.createElement(_HiInput.default, (0, _extends2.default)({
548
607
  value: searchValue,
549
608
  autoFocus: true,
@@ -567,7 +626,7 @@ function (_React$PureComponent) {
567
626
  var nbItems = itemList.length <= 10 ? itemList.length + 1 : 11;
568
627
  popperStyle.transform = "translate3d(-1px, -".concat(nbItems * 40 + 2, "px, 0px)");
569
628
  } else if (this.placement && this.placement.indexOf('top') < 0 && !!searchable) {
570
- popperStyle.transform = "translate3d(-1px, 40px, 0px)";
629
+ popperStyle.transform = 'translate3d(-1px, 40px, 0px)';
571
630
  }
572
631
 
573
632
  var content = function content(_ref) {
@@ -624,6 +683,7 @@ function (_React$PureComponent) {
624
683
  onClick: this.handleClick,
625
684
  onFocus: this.handleFocus,
626
685
  onBlur: this.handleBlur,
686
+ onKeyDown: this.handleKeyDownInput,
627
687
  onSubmit: onSubmit,
628
688
  onMouseEnter: this.props.onMouseEnter,
629
689
  onMouseLeave: this.props.onMouseLeave,
@@ -172,6 +172,8 @@ function (_React$PureComponent) {
172
172
 
173
173
  if (_this.props.onKeyDown) {
174
174
  _this.props.onKeyDown(event);
175
+
176
+ event.preventDefault();
175
177
  } else if (key === 'down' || key === 'up') {
176
178
  _this.props.onClick();
177
179
  } else if (key === 'enter' && _this.props.onSubmit) {
@@ -193,8 +195,12 @@ function (_React$PureComponent) {
193
195
  };
194
196
 
195
197
  _this.handleClick = function (event) {
198
+ // Do not open select if press on resetIcon
196
199
  if ((!_this.resetIcon || !_this.resetIcon.contains(event.target)) && _this.props.onClick) {
197
- _this.props.onClick(event);
200
+ // Do not open select if press enter on button => submit form
201
+ if (event.type !== 'keydown' || (0, _keycode.default)(event) !== 'enter') {
202
+ _this.props.onClick(event);
203
+ }
198
204
  }
199
205
  };
200
206
 
@@ -269,6 +275,7 @@ function (_React$PureComponent) {
269
275
  }, value || placeholder), _react.default.createElement(_ArrowDropDown.default, {
270
276
  className: iconClass
271
277
  })) : _react.default.createElement(_ButtonBase.default, {
278
+ component: "div",
272
279
  id: id,
273
280
  className: rootClass,
274
281
  onClick: this.handleClick,
@@ -33,8 +33,6 @@ var _HiSelectableListItem = _interopRequireDefault(require("./HiSelectableListIt
33
33
 
34
34
  var _helpers = require("../utils/helpers");
35
35
 
36
- var _keycode = _interopRequireDefault(require("keycode"));
37
-
38
36
  var styles = function styles() {
39
37
  return {
40
38
  root: {
@@ -73,35 +71,6 @@ function (_React$PureComponent) {
73
71
  };
74
72
  };
75
73
 
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
-
101
- _this.handleKeyUp = function () {
102
- return false;
103
- };
104
-
105
74
  _this.buildRecursiveListItem = function (item) {
106
75
  var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
107
76
  var _this$props = _this.props,
@@ -113,10 +82,8 @@ function (_React$PureComponent) {
113
82
  icon = _this$props.icon,
114
83
  selectedItemIdList = _this$props.selectedItemIdList,
115
84
  sort = _this$props.sort,
116
- _this$props$onKeyDown = _this$props.onKeyDown,
117
- onKeyDown = _this$props$onKeyDown === void 0 ? _this.handleKeyDown : _this$props$onKeyDown,
118
- _this$props$onKeyUp = _this$props.onKeyUp,
119
- onKeyUp = _this$props$onKeyUp === void 0 ? _this.handleKeyUp : _this$props$onKeyUp,
85
+ onKeyDown = _this$props.onKeyDown,
86
+ onKeyUp = _this$props.onKeyUp,
120
87
  others = (0, _objectWithoutProperties2.default)(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "selectedItemIdList", "sort", "onKeyDown", "onKeyUp"]);
121
88
 
122
89
  if (sort && item.children) {