@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 +58 -0
- package/HiAlertModal/HiAlertModal.js +56 -13
- package/HiForm/HiFormControl.js +2 -4
- package/HiForm/HiInput.js +16 -4
- package/HiForm/HiUploadField.js +2 -1
- package/HiSelect/HiSelect.js +6 -5
- package/HiSelect/HiSuggestSelect.js +2 -1
- package/HiSelect/SelectInput.js +1 -0
- package/HiSelectNew/HiSelect.js +78 -18
- package/HiSelectNew/HiSelectInput.js +8 -1
- package/HiSelectableList/HiSelectableList.js +2 -35
- package/es/HiAlertModal/HiAlertModal.js +55 -13
- package/es/HiForm/HiFormControl.js +2 -4
- package/es/HiForm/HiInput.js +16 -4
- package/es/HiForm/HiUploadField.js +2 -1
- package/es/HiSelect/HiSelect.js +6 -5
- package/es/HiSelect/HiSuggestSelect.js +2 -1
- package/es/HiSelect/SelectInput.js +1 -0
- package/es/HiSelectNew/HiSelect.js +80 -18
- package/es/HiSelectNew/HiSelectInput.js +7 -1
- package/es/HiSelectableList/HiSelectableList.js +3 -29
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +5717 -1273
- package/umd/hipay-material-ui.production.min.js +2 -2
|
@@ -10,18 +10,25 @@ import DialogContentText from '@material-ui/core/DialogContentText';
|
|
|
10
10
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
11
11
|
import { withStyles } from '../styles';
|
|
12
12
|
import HiButton from '../HiButton';
|
|
13
|
+
import HiIcon from '../HiIcon';
|
|
13
14
|
export const styles = theme => ({
|
|
14
15
|
classContent: {
|
|
15
16
|
fontSize: 14,
|
|
16
|
-
lineHeight: '
|
|
17
|
-
color: '#484848'
|
|
17
|
+
lineHeight: '20px',
|
|
18
|
+
color: '#484848',
|
|
19
|
+
position: 'relative'
|
|
18
20
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
classDialogPaper: {
|
|
22
|
+
minHeight: 280,
|
|
23
|
+
maxWidth: 280,
|
|
24
|
+
borderRadius: 2
|
|
21
25
|
},
|
|
22
26
|
classCancelButton: {
|
|
23
27
|
float: 'right'
|
|
24
28
|
},
|
|
29
|
+
classSubmitButton: {
|
|
30
|
+
margin: '0'
|
|
31
|
+
},
|
|
25
32
|
classTitle: {
|
|
26
33
|
fontSize: 20,
|
|
27
34
|
fontFamily: theme.typography.fontFamily,
|
|
@@ -29,10 +36,20 @@ export const styles = theme => ({
|
|
|
29
36
|
lineHeight: '24px'
|
|
30
37
|
},
|
|
31
38
|
classAction: {
|
|
32
|
-
display: 'inline-block'
|
|
39
|
+
display: 'inline-block',
|
|
40
|
+
margin: '0',
|
|
41
|
+
padding: '0px 24px 24px 24px'
|
|
33
42
|
},
|
|
34
43
|
classDialogRoot: {
|
|
35
44
|
backgroundColor: 'rgba(0, 0, 0, 0.28)'
|
|
45
|
+
},
|
|
46
|
+
classBackgroundIcon: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 'calc(50%)',
|
|
49
|
+
left: '50%',
|
|
50
|
+
transform: 'translate(-50%, -50%)',
|
|
51
|
+
color: theme.palette.background2,
|
|
52
|
+
flex: '1'
|
|
36
53
|
}
|
|
37
54
|
});
|
|
38
55
|
/**
|
|
@@ -71,6 +88,8 @@ class HiAlertModal extends React.PureComponent {
|
|
|
71
88
|
render() {
|
|
72
89
|
const _this$props = this.props,
|
|
73
90
|
{
|
|
91
|
+
backgroundIcon,
|
|
92
|
+
iconSize,
|
|
74
93
|
classes,
|
|
75
94
|
content,
|
|
76
95
|
labelCancelButton,
|
|
@@ -78,19 +97,25 @@ class HiAlertModal extends React.PureComponent {
|
|
|
78
97
|
onCancelClick,
|
|
79
98
|
onSubmitClick,
|
|
80
99
|
open,
|
|
100
|
+
cancelColor,
|
|
81
101
|
submitColor,
|
|
82
102
|
title
|
|
83
103
|
} = _this$props,
|
|
84
|
-
props = _objectWithoutProperties(_this$props, ["classes", "content", "labelCancelButton", "labelSubmitButton", "onCancelClick", "onSubmitClick", "open", "submitColor", "title"]);
|
|
104
|
+
props = _objectWithoutProperties(_this$props, ["backgroundIcon", "iconSize", "classes", "content", "labelCancelButton", "labelSubmitButton", "onCancelClick", "onSubmitClick", "open", "cancelColor", "submitColor", "title"]);
|
|
85
105
|
|
|
86
106
|
return React.createElement(Dialog, _extends({
|
|
87
107
|
open: open,
|
|
88
108
|
onClose: this.handleOnClose,
|
|
89
109
|
classes: {
|
|
90
|
-
|
|
91
|
-
|
|
110
|
+
root: classes.classDialogRoot,
|
|
111
|
+
paper: classes.classDialogPaper
|
|
92
112
|
}
|
|
93
|
-
}, props), React.createElement(
|
|
113
|
+
}, props), backgroundIcon && React.createElement("div", {
|
|
114
|
+
className: classes.classBackgroundIcon
|
|
115
|
+
}, React.createElement(HiIcon, {
|
|
116
|
+
icon: backgroundIcon,
|
|
117
|
+
size: iconSize
|
|
118
|
+
})), React.createElement(DialogTitle, {
|
|
94
119
|
disableTypography: true,
|
|
95
120
|
classes: {
|
|
96
121
|
root: classes.classTitle
|
|
@@ -103,21 +128,38 @@ class HiAlertModal extends React.PureComponent {
|
|
|
103
128
|
classes: {
|
|
104
129
|
root: classes.classAction
|
|
105
130
|
}
|
|
106
|
-
}, React.createElement(HiButton, {
|
|
131
|
+
}, labelSubmitButton && React.createElement(HiButton, {
|
|
132
|
+
classes: {
|
|
133
|
+
root: classes.classSubmitButton
|
|
134
|
+
},
|
|
107
135
|
onClick: this.handleClickSubmit,
|
|
108
136
|
color: submitColor
|
|
109
|
-
}, labelSubmitButton), React.createElement(HiButton, {
|
|
137
|
+
}, labelSubmitButton), labelCancelButton && React.createElement(HiButton, {
|
|
110
138
|
classes: {
|
|
111
139
|
root: classes.classCancelButton
|
|
112
140
|
},
|
|
113
141
|
onClick: this.handleClickCancel,
|
|
114
|
-
color:
|
|
142
|
+
color: cancelColor
|
|
115
143
|
}, labelCancelButton)));
|
|
116
144
|
}
|
|
117
145
|
|
|
118
146
|
}
|
|
119
147
|
|
|
148
|
+
HiAlertModal.defaultProps = {
|
|
149
|
+
cancelColor: 'neutral',
|
|
150
|
+
submitColor: 'primary'
|
|
151
|
+
};
|
|
120
152
|
HiAlertModal.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
153
|
+
/**
|
|
154
|
+
* Icon à mettre en fond
|
|
155
|
+
*/
|
|
156
|
+
backgroundIcon: PropTypes.string,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The color of the cancel button. It supports those theme colors that make sense for this component.
|
|
160
|
+
*/
|
|
161
|
+
cancelColor: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'positive', 'negative', 'middle', 'neutral']),
|
|
162
|
+
|
|
121
163
|
/**
|
|
122
164
|
* Surcharge les classes du composant
|
|
123
165
|
*/
|
|
@@ -126,7 +168,7 @@ HiAlertModal.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
126
168
|
/**
|
|
127
169
|
* Texte contenu dans la modal
|
|
128
170
|
*/
|
|
129
|
-
content: PropTypes.string,
|
|
171
|
+
content: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
|
130
172
|
|
|
131
173
|
/**
|
|
132
174
|
* Texte sur le bouton d'annulation
|
|
@@ -199,16 +199,14 @@ class HiFormControl extends React.PureComponent {
|
|
|
199
199
|
focused: !disabled && (focused || hovered)
|
|
200
200
|
}, InputLabelProps), error && errorText && React.createElement(HiIconButton, {
|
|
201
201
|
className: classNames(classes.iconButton, classes.iconButtonError),
|
|
202
|
-
onClick: this.handleHelperClick
|
|
203
|
-
onKeyDown: this.handleKeyDown
|
|
202
|
+
onClick: this.handleHelperClick
|
|
204
203
|
}, React.createElement(Warning, {
|
|
205
204
|
className: classNames(classes.icon)
|
|
206
205
|
})), helperIcon && helperText && !error && React.createElement(HiIconButton, {
|
|
207
206
|
className: classNames(classes.iconButton, classes.iconButtonInfo, {
|
|
208
207
|
[classes.iconButtonInfoActive]: helperOpen
|
|
209
208
|
}),
|
|
210
|
-
onClick: this.handleHelperClick
|
|
211
|
-
onKeyDown: this.handleKeyDown
|
|
209
|
+
onClick: this.handleHelperClick
|
|
212
210
|
}, React.createElement(Info, {
|
|
213
211
|
className: classNames(classes.icon)
|
|
214
212
|
}))), React.createElement("div", {
|
package/es/HiForm/HiInput.js
CHANGED
|
@@ -177,10 +177,15 @@ class HiInput extends React.PureComponent {
|
|
|
177
177
|
// Si on click sur un élément de HiInput, on garde le focus
|
|
178
178
|
// Par exemple sur l'icone reset
|
|
179
179
|
if (event.relatedTarget && this.overlayNode && this.overlayNode.contains(event.relatedTarget)) {
|
|
180
|
-
|
|
180
|
+
// If blur came from erase icon => stay focused and don't call onBlur props
|
|
181
|
+
if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
event.stopPropagation();
|
|
184
|
+
} else if (this.endAdornmentNode.contains(event.relatedTarget) && this.props.onBlur) {
|
|
181
185
|
this.props.onBlur(event);
|
|
182
186
|
}
|
|
183
187
|
|
|
188
|
+
event.preventDefault();
|
|
184
189
|
event.stopPropagation();
|
|
185
190
|
} else {
|
|
186
191
|
this.setState({
|
|
@@ -201,9 +206,13 @@ class HiInput extends React.PureComponent {
|
|
|
201
206
|
this.setState({
|
|
202
207
|
focused: true
|
|
203
208
|
});
|
|
204
|
-
}
|
|
209
|
+
} // If focus came from erase icon => stay focused and don't call onFocus props
|
|
210
|
+
|
|
205
211
|
|
|
206
|
-
if (this.
|
|
212
|
+
if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
event.stopPropagation();
|
|
215
|
+
} else if (this.props.onFocus) {
|
|
207
216
|
this.props.onFocus(event);
|
|
208
217
|
}
|
|
209
218
|
}
|
|
@@ -306,7 +315,10 @@ class HiInput extends React.PureComponent {
|
|
|
306
315
|
label: classes.eraseButtonLabel
|
|
307
316
|
},
|
|
308
317
|
onClick: this.handleReset,
|
|
309
|
-
onBlur: this.handleBlur
|
|
318
|
+
onBlur: this.handleBlur,
|
|
319
|
+
buttonRef: el => {
|
|
320
|
+
this.eraseIconNode = el;
|
|
321
|
+
}
|
|
310
322
|
}, _ref);
|
|
311
323
|
let endAdornment = endAdornmentProps;
|
|
312
324
|
|
package/es/HiSelect/HiSelect.js
CHANGED
|
@@ -193,17 +193,13 @@ class HiSelect extends React.PureComponent {
|
|
|
193
193
|
nextItem = getNextItemSelectable(document.activeElement, 'down');
|
|
194
194
|
} else if (event.key === 'ArrowUp') {
|
|
195
195
|
nextItem = getNextItemSelectable(document.activeElement, 'up');
|
|
196
|
-
} else if (event.key === 'Tab') {
|
|
196
|
+
} else if (event.key === 'Tab' || event.key === 'Escape') {
|
|
197
197
|
/* if (!this.props.staticPosition) {
|
|
198
198
|
document.body.style.overflow = 'auto';
|
|
199
199
|
} */
|
|
200
200
|
this.setState({
|
|
201
201
|
open: false
|
|
202
202
|
});
|
|
203
|
-
} else if (event.key === 'Escape') {
|
|
204
|
-
this.setState({
|
|
205
|
-
open: false
|
|
206
|
-
});
|
|
207
203
|
}
|
|
208
204
|
|
|
209
205
|
if (nextItem) {
|
|
@@ -216,6 +212,10 @@ class HiSelect extends React.PureComponent {
|
|
|
216
212
|
this.focusOnSelectedItem();
|
|
217
213
|
} else if (event.key === 'Enter' && this.props.onSubmit) {
|
|
218
214
|
this.props.onSubmit(event);
|
|
215
|
+
} else if (event.key === 'Tab' || event.key === 'Escape') {
|
|
216
|
+
this.setState({
|
|
217
|
+
open: false
|
|
218
|
+
});
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
|
|
@@ -682,6 +682,7 @@ class HiSelect extends React.PureComponent {
|
|
|
682
682
|
onClick: this.handleClick,
|
|
683
683
|
onFocus: this.handleFocus,
|
|
684
684
|
onBlur: this.handleBlur,
|
|
685
|
+
onKeyDown: this.handleKeyDown,
|
|
685
686
|
onMouseEnter: this.props.onMouseEnter,
|
|
686
687
|
onMouseLeave: this.props.onMouseLeave,
|
|
687
688
|
refElement: el => {
|
|
@@ -6,7 +6,6 @@ import Scrollbars from 'react-custom-scrollbars';
|
|
|
6
6
|
import Grow from '@material-ui/core/Grow';
|
|
7
7
|
import Paper from '@material-ui/core/Paper';
|
|
8
8
|
import Popper from '@material-ui/core/Popper';
|
|
9
|
-
import { findDOMNode } from 'react-dom';
|
|
10
9
|
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
|
|
11
10
|
import HiSelectableList from '../HiSelectableList';
|
|
12
11
|
import HiInput from '../HiForm/HiInput';
|
|
@@ -164,11 +163,12 @@ class HiSelect extends React.PureComponent {
|
|
|
164
163
|
};
|
|
165
164
|
|
|
166
165
|
this.focusOnFirstItem = () => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
if (this.overlay && this.overlay.getElementsByTagName('li')[0]) {
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
const item = this.overlay.getElementsByTagName('li')[0];
|
|
169
|
+
item.focus();
|
|
170
|
+
}, 1);
|
|
171
|
+
}
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
this.getInputElement = el => {
|
|
@@ -204,15 +204,14 @@ class HiSelect extends React.PureComponent {
|
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
this.focusOnSelectedItem = selectedValue => {
|
|
207
|
-
const overlay = findDOMNode(this.overlay);
|
|
208
207
|
setTimeout(() => {
|
|
209
208
|
// On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
|
|
210
|
-
let item = overlay.getElementsByTagName('li')[0];
|
|
209
|
+
let item = this.overlay.getElementsByTagName('li')[0];
|
|
211
210
|
|
|
212
211
|
if (selectedValue && typeof selectedValue === 'string') {
|
|
213
|
-
item = overlay.getElementsByTagName('li')[selectedValue];
|
|
212
|
+
item = this.overlay.getElementsByTagName('li')[selectedValue];
|
|
214
213
|
} else if (selectedValue && typeof selectedValue === 'number') {
|
|
215
|
-
item = overlay.getElementsByTagName('li')[selectedValue - 1];
|
|
214
|
+
item = this.overlay.getElementsByTagName('li')[selectedValue - 1];
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
if (item) {
|
|
@@ -249,6 +248,17 @@ class HiSelect extends React.PureComponent {
|
|
|
249
248
|
});
|
|
250
249
|
};
|
|
251
250
|
|
|
251
|
+
this.handleKeyDownInput = event => {
|
|
252
|
+
const key = keycode(event);
|
|
253
|
+
|
|
254
|
+
if (key === 'down' || key === 'up') {
|
|
255
|
+
this.handleClick();
|
|
256
|
+
} else if (key === 'enter' && this.props.onSubmit) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
this.props.onSubmit(event);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
252
262
|
this.handleKeyDown = event => {
|
|
253
263
|
let nextItem;
|
|
254
264
|
const key = keycode(event);
|
|
@@ -259,6 +269,13 @@ class HiSelect extends React.PureComponent {
|
|
|
259
269
|
} else if (key === 'up') {
|
|
260
270
|
event.preventDefault();
|
|
261
271
|
nextItem = getNextItemSelectable(document.activeElement, 'up');
|
|
272
|
+
} else if (key === 'tab' || key === 'esc') {
|
|
273
|
+
this.setState({
|
|
274
|
+
open: false
|
|
275
|
+
});
|
|
276
|
+
} else if (key === 'space') {
|
|
277
|
+
// Cancel scroll
|
|
278
|
+
event.preventDefault();
|
|
262
279
|
}
|
|
263
280
|
|
|
264
281
|
if (nextItem) {
|
|
@@ -266,17 +283,57 @@ class HiSelect extends React.PureComponent {
|
|
|
266
283
|
}
|
|
267
284
|
};
|
|
268
285
|
|
|
286
|
+
this.getItemById = id => {
|
|
287
|
+
let item;
|
|
288
|
+
|
|
289
|
+
if (this.props.hasAll && String(id) === '_all') {
|
|
290
|
+
return {
|
|
291
|
+
id: '_all'
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
for (let i = 0; i < this.props.options.length; i += 1) {
|
|
296
|
+
const elem = this.props.options[i];
|
|
297
|
+
|
|
298
|
+
if (String(elem.id) === String(id)) {
|
|
299
|
+
item = elem;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (elem.children) {
|
|
304
|
+
for (let j = 0; j < elem.children.length; j += 1) {
|
|
305
|
+
if (String(elem.children[j].id) === String(id)) {
|
|
306
|
+
item = elem.children[j];
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return item;
|
|
314
|
+
};
|
|
315
|
+
|
|
269
316
|
this.handleKeyUp = event => {
|
|
270
317
|
const key = keycode(event);
|
|
271
318
|
|
|
272
|
-
if (key === '
|
|
319
|
+
if (key === 'esc') {
|
|
273
320
|
this.setState({
|
|
274
321
|
open: false
|
|
275
322
|
});
|
|
276
323
|
} else if (key === 'space' || key === 'enter' && !this.props.multiple) {
|
|
277
324
|
event.preventDefault();
|
|
278
|
-
const item = this.
|
|
279
|
-
|
|
325
|
+
const item = this.getItemById(event.target.id);
|
|
326
|
+
|
|
327
|
+
if (item) {
|
|
328
|
+
// Select for nested select
|
|
329
|
+
if (this.props.hiSelectableListProps && this.props.hiSelectableListProps.onSelect) {
|
|
330
|
+
this.props.hiSelectableListProps.onSelect(null, item);
|
|
331
|
+
} else {
|
|
332
|
+
this.handleSelect(null, item);
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
console.warn(`Can not find item #${event.target.id}`);
|
|
336
|
+
}
|
|
280
337
|
} else if (key === 'enter' && this.props.multiple) {
|
|
281
338
|
event.preventDefault();
|
|
282
339
|
this.handleClose();
|
|
@@ -291,6 +348,10 @@ class HiSelect extends React.PureComponent {
|
|
|
291
348
|
} else if (this.overlay && key === 'esc' || key === 'enter') {
|
|
292
349
|
event.preventDefault();
|
|
293
350
|
this.handleClose();
|
|
351
|
+
} else if (key === 'tab') {
|
|
352
|
+
this.setState({
|
|
353
|
+
open: false
|
|
354
|
+
});
|
|
294
355
|
}
|
|
295
356
|
};
|
|
296
357
|
|
|
@@ -484,8 +545,8 @@ class HiSelect extends React.PureComponent {
|
|
|
484
545
|
[classes.popperRightAlign]: this.props.containerWidth && this.props.align === 'right'
|
|
485
546
|
});
|
|
486
547
|
|
|
487
|
-
|
|
488
|
-
if (
|
|
548
|
+
const searchInput = position => {
|
|
549
|
+
if (searchable) {
|
|
489
550
|
return React.createElement(HiInput, _extends({
|
|
490
551
|
value: searchValue,
|
|
491
552
|
autoFocus: true,
|
|
@@ -508,13 +569,13 @@ class HiSelect extends React.PureComponent {
|
|
|
508
569
|
|
|
509
570
|
if (this.placement && this.placement.indexOf('top') >= 0 && !!searchable) {
|
|
510
571
|
// +1 for search input
|
|
511
|
-
|
|
572
|
+
const nbItems = itemList.length <= 10 ? itemList.length + 1 : 11;
|
|
512
573
|
popperStyle.transform = `translate3d(-1px, -${nbItems * 40 + 2}px, 0px)`;
|
|
513
574
|
} else if (this.placement && this.placement.indexOf('top') < 0 && !!searchable) {
|
|
514
|
-
popperStyle.transform =
|
|
575
|
+
popperStyle.transform = 'translate3d(-1px, 40px, 0px)';
|
|
515
576
|
}
|
|
516
577
|
|
|
517
|
-
|
|
578
|
+
const content = ({
|
|
518
579
|
placement
|
|
519
580
|
}) => {
|
|
520
581
|
if (placement !== this.placement) {
|
|
@@ -568,6 +629,7 @@ class HiSelect extends React.PureComponent {
|
|
|
568
629
|
onClick: this.handleClick,
|
|
569
630
|
onFocus: this.handleFocus,
|
|
570
631
|
onBlur: this.handleBlur,
|
|
632
|
+
onKeyDown: this.handleKeyDownInput,
|
|
571
633
|
onSubmit: onSubmit,
|
|
572
634
|
onMouseEnter: this.props.onMouseEnter,
|
|
573
635
|
onMouseLeave: this.props.onMouseLeave,
|
|
@@ -127,6 +127,7 @@ class HiSelectInput extends React.PureComponent {
|
|
|
127
127
|
|
|
128
128
|
if (this.props.onKeyDown) {
|
|
129
129
|
this.props.onKeyDown(event);
|
|
130
|
+
event.preventDefault();
|
|
130
131
|
} else if (key === 'down' || key === 'up') {
|
|
131
132
|
this.props.onClick();
|
|
132
133
|
} else if (key === 'enter' && this.props.onSubmit) {
|
|
@@ -146,8 +147,12 @@ class HiSelectInput extends React.PureComponent {
|
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
this.handleClick = event => {
|
|
150
|
+
// Do not open select if press on resetIcon
|
|
149
151
|
if ((!this.resetIcon || !this.resetIcon.contains(event.target)) && this.props.onClick) {
|
|
150
|
-
|
|
152
|
+
// Do not open select if press enter on button => submit form
|
|
153
|
+
if (event.type !== 'keydown' || keycode(event) !== 'enter') {
|
|
154
|
+
this.props.onClick(event);
|
|
155
|
+
}
|
|
151
156
|
}
|
|
152
157
|
};
|
|
153
158
|
|
|
@@ -225,6 +230,7 @@ class HiSelectInput extends React.PureComponent {
|
|
|
225
230
|
}, value || placeholder), React.createElement(ArrowDropDownIcon, {
|
|
226
231
|
className: iconClass
|
|
227
232
|
})) : React.createElement(ButtonBase, {
|
|
233
|
+
component: "div",
|
|
228
234
|
id: id,
|
|
229
235
|
className: rootClass,
|
|
230
236
|
onClick: this.handleClick,
|
|
@@ -5,8 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import List from '@material-ui/core/List';
|
|
6
6
|
import withStyles from '../styles/withStyles';
|
|
7
7
|
import HiSelectableListItem from './HiSelectableListItem';
|
|
8
|
-
import { foldAccents
|
|
9
|
-
import keycode from 'keycode';
|
|
8
|
+
import { foldAccents } from '../utils/helpers';
|
|
10
9
|
export const styles = () => ({
|
|
11
10
|
root: {
|
|
12
11
|
padding: 0
|
|
@@ -24,31 +23,6 @@ class HiSelectableList extends React.PureComponent {
|
|
|
24
23
|
this.props.onSelect(event, item);
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
this.handleKeyDown = event => {
|
|
28
|
-
let nextItem;
|
|
29
|
-
const key = keycode(event);
|
|
30
|
-
|
|
31
|
-
if (key === 'down') {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
nextItem = getNextItemSelectable(document.activeElement, 'down');
|
|
34
|
-
} else if (key === 'up') {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
nextItem = getNextItemSelectable(document.activeElement, 'up');
|
|
37
|
-
} else if (key === 'space' || key === 'enter' && !this.props.multiple) {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
const item = this.props.options.find(elem => String(elem.id) === event.target.id);
|
|
40
|
-
this.handleSelect(null, item);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (nextItem) {
|
|
44
|
-
nextItem.focus();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
this.handleKeyUp = () => {
|
|
49
|
-
return false;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
26
|
this.buildRecursiveListItem = (item, level = 0) => {
|
|
53
27
|
const _this$props = this.props,
|
|
54
28
|
{
|
|
@@ -60,8 +34,8 @@ class HiSelectableList extends React.PureComponent {
|
|
|
60
34
|
icon,
|
|
61
35
|
selectedItemIdList,
|
|
62
36
|
sort,
|
|
63
|
-
onKeyDown
|
|
64
|
-
onKeyUp
|
|
37
|
+
onKeyDown,
|
|
38
|
+
onKeyUp
|
|
65
39
|
} = _this$props,
|
|
66
40
|
others = _objectWithoutProperties(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "selectedItemIdList", "sort", "onKeyDown", "onKeyUp"]);
|
|
67
41
|
|
package/index.es.js
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED