@hipay/hipay-material-ui 2.0.0-beta.39 → 2.0.0-beta.41
Sign up to get free protection for your applications and to get access to all the features.
- package/HiCheckbox/HiCheckbox.js +2 -2
- package/HiForm/HiInput.js +7 -0
- package/HiIcon/HiIcon.js +1 -1
- package/HiIconButton/HiIconButton.js +3 -1
- package/HiSelect/HiSelect.js +15 -2
- package/HiSelect/SelectInput.js +32 -6
- package/HiSelectNew/HiDynamicSelectField.js +146 -0
- package/HiSelectNew/HiNestedSelect.js +33 -4
- package/HiSelectNew/HiNestedSelectField.js +146 -0
- package/HiSelectNew/HiSelect.js +34 -6
- package/HiSelectNew/HiSelectInput.js +33 -5
- package/es/HiCheckbox/HiCheckbox.js +2 -2
- package/es/HiForm/HiInput.js +7 -0
- package/es/HiIcon/HiIcon.js +2 -2
- package/es/HiIconButton/HiIconButton.js +3 -1
- package/es/HiSelect/HiSelect.js +14 -2
- package/es/HiSelect/SelectInput.js +29 -5
- package/es/HiSelectNew/HiDynamicSelectField.js +111 -0
- package/es/HiSelectNew/HiNestedSelect.js +25 -4
- package/es/HiSelectNew/HiNestedSelectField.js +111 -0
- package/es/HiSelectNew/HiSelect.js +33 -6
- package/es/HiSelectNew/HiSelectInput.js +29 -4
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +61 -13
- package/umd/hipay-material-ui.production.min.js +2 -2
@@ -35,6 +35,8 @@ var _ButtonBase = _interopRequireDefault(require("@material-ui/core/ButtonBase")
|
|
35
35
|
|
36
36
|
var _Icon = _interopRequireDefault(require("@material-ui/core/Icon"));
|
37
37
|
|
38
|
+
var _HiIcon = _interopRequireDefault(require("../HiIcon"));
|
39
|
+
|
38
40
|
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
39
41
|
|
40
42
|
var _keycode = _interopRequireDefault(require("keycode"));
|
@@ -179,27 +181,38 @@ function (_React$PureComponent) {
|
|
179
181
|
}
|
180
182
|
};
|
181
183
|
|
184
|
+
_this.handleClick = function (event) {
|
185
|
+
if ((!_this.resetIcon || !_this.resetIcon.contains(event.target)) && _this.props.onClick) {
|
186
|
+
_this.props.onClick(event);
|
187
|
+
}
|
188
|
+
};
|
189
|
+
|
182
190
|
_this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
191
|
+
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
183
192
|
return _this;
|
184
193
|
}
|
185
194
|
|
186
195
|
(0, _createClass2.default)(HiSelectInput, [{
|
187
196
|
key: "render",
|
188
197
|
value: function render() {
|
189
|
-
var _classNames,
|
198
|
+
var _classNames,
|
199
|
+
_classNames2,
|
200
|
+
_this2 = this;
|
190
201
|
|
191
202
|
var _this$props = this.props,
|
192
203
|
classes = _this$props.classes,
|
193
204
|
noButton = _this$props.noButton,
|
194
205
|
disabled = _this$props.disabled,
|
195
206
|
onClick = _this$props.onClick,
|
207
|
+
onReset = _this$props.onReset,
|
196
208
|
value = _this$props.value,
|
197
209
|
open = _this$props.open,
|
198
210
|
focused = _this$props.focused,
|
199
211
|
error = _this$props.error,
|
200
212
|
id = _this$props.id,
|
201
213
|
placeholder = _this$props.placeholder,
|
202
|
-
refElement = _this$props.refElement
|
214
|
+
refElement = _this$props.refElement,
|
215
|
+
theme = _this$props.theme; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
203
216
|
|
204
217
|
var rootClass = (0, _classnames.default)(classes.root, classes.inkbar, classes.underline, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.disabled, disabled), (0, _defineProperty2.default)(_classNames, classes.focused, focused), (0, _defineProperty2.default)(_classNames, classes.error, error && !focused), _classNames));
|
205
218
|
var iconClass = (0, _classnames.default)(classes.icon, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, classes.iconOpen, open), (0, _defineProperty2.default)(_classNames2, classes.iconClose, !open), _classNames2));
|
@@ -224,7 +237,7 @@ function (_React$PureComponent) {
|
|
224
237
|
})) : _react.default.createElement(_ButtonBase.default, {
|
225
238
|
id: id,
|
226
239
|
className: rootClass,
|
227
|
-
onClick:
|
240
|
+
onClick: this.handleClick,
|
228
241
|
disabled: disabled,
|
229
242
|
onMouseEnter: this.props.onMouseEnter,
|
230
243
|
onMouseLeave: this.props.onMouseLeave,
|
@@ -236,7 +249,16 @@ function (_React$PureComponent) {
|
|
236
249
|
}
|
237
250
|
}, _react.default.createElement("span", {
|
238
251
|
className: (0, _classnames.default)(classes.label, (0, _defineProperty2.default)({}, classes.placeholder, value === undefined))
|
239
|
-
}, value || placeholder), _react.default.createElement(
|
252
|
+
}, value || placeholder), onReset && focused && _react.default.createElement("div", {
|
253
|
+
ref: function ref(el) {
|
254
|
+
_this2.resetIcon = el;
|
255
|
+
}
|
256
|
+
}, _react.default.createElement(_HiIcon.default, {
|
257
|
+
icon: "close",
|
258
|
+
size: 24,
|
259
|
+
color: theme.palette.neutral.main,
|
260
|
+
onClick: onReset
|
261
|
+
})), _react.default.createElement(_Icon.default, {
|
240
262
|
classes: {
|
241
263
|
root: iconClass
|
242
264
|
}
|
@@ -315,6 +337,11 @@ HiSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
315
337
|
*/
|
316
338
|
onMouseLeave: _propTypes.default.func,
|
317
339
|
|
340
|
+
/**
|
341
|
+
* Fonction de callback appelée lorsqu'on vide le champs
|
342
|
+
*/
|
343
|
+
onReset: _propTypes.default.func,
|
344
|
+
|
318
345
|
/**
|
319
346
|
* Fonction de callback à la pression de la touche "Entrée"
|
320
347
|
*/
|
@@ -343,7 +370,8 @@ HiSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
343
370
|
|
344
371
|
var _default = (0, _withStyles.default)(styles, {
|
345
372
|
hiComponent: true,
|
346
|
-
name: 'HmuiHiSelectInput'
|
373
|
+
name: 'HmuiHiSelectInput',
|
374
|
+
withTheme: true
|
347
375
|
})(HiSelectInput);
|
348
376
|
|
349
377
|
exports.default = _default;
|
@@ -125,7 +125,7 @@ class HiCheckbox extends React.Component {
|
|
125
125
|
|
126
126
|
HiCheckbox.defaultProps = {
|
127
127
|
checked: false,
|
128
|
-
color: '
|
128
|
+
color: 'inherit',
|
129
129
|
size: 20,
|
130
130
|
icon: 'check_box_outline_blank'
|
131
131
|
};
|
@@ -148,7 +148,7 @@ HiCheckbox.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
148
148
|
/**
|
149
149
|
* The color of the component. It supports those theme colors that make sense for this component.
|
150
150
|
*/
|
151
|
-
color: PropTypes.oneOf(['
|
151
|
+
color: PropTypes.oneOf(['inherit', 'primary', 'secondary', 'positive', 'negative', 'middle', 'neutral']),
|
152
152
|
|
153
153
|
/**
|
154
154
|
* icon à afficher quand le composant est non coché.
|
package/es/HiForm/HiInput.js
CHANGED
@@ -104,6 +104,10 @@ export const styles = theme => ({
|
|
104
104
|
width: 40,
|
105
105
|
display: 'inline-block'
|
106
106
|
},
|
107
|
+
eraseButtonLabel: {
|
108
|
+
position: 'relative',
|
109
|
+
top: -2
|
110
|
+
},
|
107
111
|
disabled: {
|
108
112
|
borderBottom: 'none'
|
109
113
|
},
|
@@ -288,6 +292,9 @@ class HiInput extends React.PureComponent {
|
|
288
292
|
|
289
293
|
const eraseIcon = !multiline && onReset && focused && !disabled && value.length > 0 && React.createElement(HiIconButton, {
|
290
294
|
className: classes.eraseButton,
|
295
|
+
classes: {
|
296
|
+
label: classes.eraseButtonLabel
|
297
|
+
},
|
291
298
|
onClick: this.handleReset,
|
292
299
|
onBlur: this.handleBlur
|
293
300
|
}, _ref);
|
package/es/HiIcon/HiIcon.js
CHANGED
@@ -65,9 +65,9 @@ function HiIcon(props) {
|
|
65
65
|
|
66
66
|
if (iconName.indexOf('fa-') === 0) {
|
67
67
|
return React.createElement("i", _extends({
|
68
|
-
className: classNames('fa', iconName, classes.root, {
|
68
|
+
className: classNames('fa', iconName, className, classes.root, {
|
69
69
|
[classes[`color${capitalize(color)}`]]: color !== 'inherit'
|
70
|
-
}
|
70
|
+
}),
|
71
71
|
style: {
|
72
72
|
fontSize: size
|
73
73
|
}
|
@@ -8,6 +8,7 @@ import { withStyles } from '../styles';
|
|
8
8
|
import { fade } from '../styles/colorManipulator';
|
9
9
|
import IconButton from '@material-ui/core/IconButton';
|
10
10
|
export const styles = theme => ({
|
11
|
+
label: {},
|
11
12
|
positive: {
|
12
13
|
color: theme.palette.positive.main,
|
13
14
|
'&:hover': {
|
@@ -69,7 +70,8 @@ function HiIconButton(props) {
|
|
69
70
|
return React.createElement(IconButton, _extends({
|
70
71
|
className: className,
|
71
72
|
classes: {
|
72
|
-
root: buttonClassNames
|
73
|
+
root: buttonClassNames,
|
74
|
+
label: classes.label
|
73
75
|
},
|
74
76
|
color: hcolor
|
75
77
|
}, other), children);
|
package/es/HiSelect/HiSelect.js
CHANGED
@@ -488,6 +488,13 @@ class HiSelect extends React.PureComponent {
|
|
488
488
|
}
|
489
489
|
}
|
490
490
|
|
491
|
+
handleReset(event) {
|
492
|
+
if (this.props.onReset) {
|
493
|
+
event.stopPropagation();
|
494
|
+
this.props.onReset(event);
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
491
498
|
render() {
|
492
499
|
const _this$props = this.props,
|
493
500
|
{
|
@@ -683,14 +690,14 @@ class HiSelect extends React.PureComponent {
|
|
683
690
|
onMouseLeave: this.props.onMouseLeave,
|
684
691
|
refElement: el => {
|
685
692
|
this.selectInputElement = el;
|
686
|
-
}
|
693
|
+
},
|
694
|
+
onReset: this.props.onReset
|
687
695
|
}), open && staticPosition ? React.createElement("div", {
|
688
696
|
style: popperStyle
|
689
697
|
}, content) : React.createElement(Popper, {
|
690
698
|
anchorEl: this.inputEl,
|
691
699
|
placement: "bottom-start",
|
692
700
|
open: open,
|
693
|
-
eventsEnabled: open,
|
694
701
|
className: popperClass,
|
695
702
|
style: popperStyle,
|
696
703
|
disablePortal: true
|
@@ -861,6 +868,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
861
868
|
*/
|
862
869
|
onMouseLeave: PropTypes.func,
|
863
870
|
|
871
|
+
/**
|
872
|
+
* Fonction de callback appelée lorsqu'on vide le champs
|
873
|
+
*/
|
874
|
+
onReset: PropTypes.func,
|
875
|
+
|
864
876
|
/**
|
865
877
|
* Fonction de callback appelée lorsqu'on écrit dans la barre de recherche
|
866
878
|
* A utiliser pour les selects avec des données dynamiques
|
@@ -77,7 +77,7 @@ export const styles = theme => ({
|
|
77
77
|
}
|
78
78
|
},
|
79
79
|
disabled: {
|
80
|
-
color: `${theme.palette.
|
80
|
+
color: `${theme.palette.text.disabled}`,
|
81
81
|
'&:before': {
|
82
82
|
display: 'none'
|
83
83
|
}
|
@@ -126,7 +126,14 @@ class SelectInput extends React.PureComponent {
|
|
126
126
|
}
|
127
127
|
};
|
128
128
|
|
129
|
+
this.handleClick = event => {
|
130
|
+
if ((!this.resetIcon || !this.resetIcon.contains(event.target)) && this.props.onClick) {
|
131
|
+
this.props.onClick(event);
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
129
135
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
136
|
+
this.handleClick = this.handleClick.bind(this);
|
130
137
|
}
|
131
138
|
|
132
139
|
render() {
|
@@ -135,12 +142,14 @@ class SelectInput extends React.PureComponent {
|
|
135
142
|
noButton,
|
136
143
|
disabled,
|
137
144
|
onClick,
|
145
|
+
onReset,
|
138
146
|
value,
|
139
147
|
open,
|
140
148
|
focused,
|
141
149
|
error,
|
142
150
|
id,
|
143
|
-
refElement
|
151
|
+
refElement,
|
152
|
+
theme
|
144
153
|
} = this.props; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
145
154
|
|
146
155
|
const rootClass = classNames(classes.root, classes.inkbar, classes.underline, {
|
@@ -177,7 +186,7 @@ class SelectInput extends React.PureComponent {
|
|
177
186
|
classes: {
|
178
187
|
root: rootClass
|
179
188
|
},
|
180
|
-
onClick:
|
189
|
+
onClick: this.handleClick,
|
181
190
|
disabled: disabled,
|
182
191
|
onMouseEnter: this.props.onMouseEnter,
|
183
192
|
onMouseLeave: this.props.onMouseLeave,
|
@@ -189,7 +198,16 @@ class SelectInput extends React.PureComponent {
|
|
189
198
|
}
|
190
199
|
}, React.createElement("span", {
|
191
200
|
className: classes.label
|
192
|
-
}, value), React.createElement(
|
201
|
+
}, value), onReset && focused && React.createElement("div", {
|
202
|
+
ref: el => {
|
203
|
+
this.resetIcon = el;
|
204
|
+
}
|
205
|
+
}, React.createElement(HiIcon, {
|
206
|
+
icon: "close",
|
207
|
+
size: 24,
|
208
|
+
color: theme.palette.neutral.main,
|
209
|
+
onClick: onReset
|
210
|
+
})), React.createElement(HiIcon, {
|
193
211
|
className: iconClass,
|
194
212
|
icon: "arrow_drop_down"
|
195
213
|
}));
|
@@ -262,6 +280,11 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
262
280
|
*/
|
263
281
|
onMouseLeave: PropTypes.func,
|
264
282
|
|
283
|
+
/**
|
284
|
+
* Fonction de callback appelée lorsqu'on vide le champs
|
285
|
+
*/
|
286
|
+
onReset: PropTypes.func,
|
287
|
+
|
265
288
|
/**
|
266
289
|
* Fonction de callback à la pression de la touche "Entrée"
|
267
290
|
*/
|
@@ -284,5 +307,6 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
284
307
|
} : {};
|
285
308
|
export default withStyles(styles, {
|
286
309
|
hiComponent: true,
|
287
|
-
name: 'HmuiSelectInput'
|
310
|
+
name: 'HmuiSelectInput',
|
311
|
+
withTheme: true
|
288
312
|
})(SelectInput);
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
// @inheritedComponent HiDynamicSelect
|
4
|
+
import React from 'react';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import HiFormControl from '../HiForm/HiFormControl';
|
7
|
+
import HiDynamicSelect from './HiDynamicSelect';
|
8
|
+
/**
|
9
|
+
* Champs input pour formulaire
|
10
|
+
*/
|
11
|
+
|
12
|
+
class HiDynamicSelectField extends React.PureComponent {
|
13
|
+
render() {
|
14
|
+
const _this$props = this.props,
|
15
|
+
{
|
16
|
+
label,
|
17
|
+
required,
|
18
|
+
disabled,
|
19
|
+
error,
|
20
|
+
errorText,
|
21
|
+
helperText,
|
22
|
+
helperIcon,
|
23
|
+
id,
|
24
|
+
name,
|
25
|
+
value,
|
26
|
+
options,
|
27
|
+
type,
|
28
|
+
multiple,
|
29
|
+
iconAll,
|
30
|
+
checkbox,
|
31
|
+
searchable,
|
32
|
+
translations,
|
33
|
+
className
|
34
|
+
} = _this$props,
|
35
|
+
others = _objectWithoutProperties(_this$props, ["label", "required", "disabled", "error", "errorText", "helperText", "helperIcon", "id", "name", "value", "options", "type", "multiple", "iconAll", "checkbox", "searchable", "translations", "className"]);
|
36
|
+
|
37
|
+
return React.createElement(HiFormControl, {
|
38
|
+
id: id,
|
39
|
+
label: label,
|
40
|
+
required: required,
|
41
|
+
disabled: disabled,
|
42
|
+
error: error,
|
43
|
+
errorText: errorText,
|
44
|
+
helperText: helperText,
|
45
|
+
helperIcon: helperIcon,
|
46
|
+
className: className
|
47
|
+
}, React.createElement(HiDynamicSelect, _extends({
|
48
|
+
id: id,
|
49
|
+
name: name,
|
50
|
+
value: value,
|
51
|
+
options: options,
|
52
|
+
type: type,
|
53
|
+
multiple: multiple,
|
54
|
+
iconAll: iconAll,
|
55
|
+
checkbox: checkbox,
|
56
|
+
searchable: searchable,
|
57
|
+
translations: translations,
|
58
|
+
disabled: disabled,
|
59
|
+
error: error
|
60
|
+
}, others)));
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
HiDynamicSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
66
|
+
/**
|
67
|
+
* Surcharge des styles
|
68
|
+
*/
|
69
|
+
className: PropTypes.string,
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Si `true`, l'input sera inactif.
|
73
|
+
*/
|
74
|
+
disabled: PropTypes.bool,
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Si `true`, le champs sera en erreur.
|
78
|
+
*/
|
79
|
+
error: PropTypes.bool,
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Texte de l'erreur
|
83
|
+
*/
|
84
|
+
errorText: PropTypes.string,
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
88
|
+
*/
|
89
|
+
helperIcon: PropTypes.bool,
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Texte de l'aide
|
93
|
+
*/
|
94
|
+
helperText: PropTypes.string,
|
95
|
+
|
96
|
+
/**
|
97
|
+
* id de l'élément input
|
98
|
+
*/
|
99
|
+
id: PropTypes.string.isRequired,
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Label du champs
|
103
|
+
*/
|
104
|
+
label: PropTypes.string,
|
105
|
+
|
106
|
+
/**
|
107
|
+
* true si champs obligatoire
|
108
|
+
*/
|
109
|
+
required: PropTypes.bool
|
110
|
+
} : {};
|
111
|
+
export default HiDynamicSelectField;
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
7
7
|
import HiSelect from './HiSelect';
|
8
8
|
import HiIcon from '../HiIcon';
|
9
|
+
import withStyles from "../styles/withStyles";
|
9
10
|
/**
|
10
11
|
* Return array of final item id in nested list (via props chlidren)
|
11
12
|
* @param itemList
|
@@ -109,6 +110,24 @@ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue =
|
|
109
110
|
v: visibleParent
|
110
111
|
});
|
111
112
|
}
|
113
|
+
|
114
|
+
export const styles = theme => ({
|
115
|
+
root: {
|
116
|
+
backgroundColor: theme.palette.background2,
|
117
|
+
maxWidth: 500,
|
118
|
+
width: '100%',
|
119
|
+
position: 'relative'
|
120
|
+
},
|
121
|
+
popper: {
|
122
|
+
// width: '100%',
|
123
|
+
zIndex: 1200
|
124
|
+
},
|
125
|
+
paper: {
|
126
|
+
borderRadius: '0px 2px',
|
127
|
+
maxHeight: 480,
|
128
|
+
transition: 'none !important'
|
129
|
+
}
|
130
|
+
});
|
112
131
|
/**
|
113
132
|
* HiNestedSelect hérite du composant HiSelect
|
114
133
|
*
|
@@ -122,7 +141,6 @@ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue =
|
|
122
141
|
* - si aucun enfant n'est sélectionné, le parent est affiché "unselected".
|
123
142
|
*/
|
124
143
|
|
125
|
-
|
126
144
|
class HiNestedSelect extends React.PureComponent {
|
127
145
|
constructor(props) {
|
128
146
|
super(props);
|
@@ -235,9 +253,9 @@ class HiNestedSelect extends React.PureComponent {
|
|
235
253
|
}), selectedItem.label);
|
236
254
|
} else if (selectedItem.type === 'image') {
|
237
255
|
inputValue = React.createElement("span", {
|
238
|
-
className: classes.
|
256
|
+
className: classes.selectImgLabel
|
239
257
|
}, React.createElement("img", {
|
240
|
-
className: classes.
|
258
|
+
className: classes.labelImg,
|
241
259
|
src: selectedItem.img,
|
242
260
|
alt: selectedItem.label
|
243
261
|
}), selectedItem.label);
|
@@ -398,4 +416,7 @@ HiNestedSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
398
416
|
*/
|
399
417
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array])
|
400
418
|
} : {};
|
401
|
-
export default
|
419
|
+
export default withStyles(styles, {
|
420
|
+
hiComponent: true,
|
421
|
+
name: 'HmuiHiNestedSelect'
|
422
|
+
})(HiNestedSelect);
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
// @inheritedComponent HiDynamicSelect
|
4
|
+
import React from 'react';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import HiFormControl from '../HiForm/HiFormControl';
|
7
|
+
import HiNestedSelect from './HiNestedSelect';
|
8
|
+
/**
|
9
|
+
* Champs input pour formulaire
|
10
|
+
*/
|
11
|
+
|
12
|
+
class HiNestedSelectField extends React.PureComponent {
|
13
|
+
render() {
|
14
|
+
const _this$props = this.props,
|
15
|
+
{
|
16
|
+
label,
|
17
|
+
required,
|
18
|
+
disabled,
|
19
|
+
error,
|
20
|
+
errorText,
|
21
|
+
helperText,
|
22
|
+
helperIcon,
|
23
|
+
id,
|
24
|
+
name,
|
25
|
+
value,
|
26
|
+
options,
|
27
|
+
type,
|
28
|
+
multiple,
|
29
|
+
iconAll,
|
30
|
+
checkbox,
|
31
|
+
searchable,
|
32
|
+
translations,
|
33
|
+
className
|
34
|
+
} = _this$props,
|
35
|
+
others = _objectWithoutProperties(_this$props, ["label", "required", "disabled", "error", "errorText", "helperText", "helperIcon", "id", "name", "value", "options", "type", "multiple", "iconAll", "checkbox", "searchable", "translations", "className"]);
|
36
|
+
|
37
|
+
return React.createElement(HiFormControl, {
|
38
|
+
id: id,
|
39
|
+
label: label,
|
40
|
+
required: required,
|
41
|
+
disabled: disabled,
|
42
|
+
error: error,
|
43
|
+
errorText: errorText,
|
44
|
+
helperText: helperText,
|
45
|
+
helperIcon: helperIcon,
|
46
|
+
className: className
|
47
|
+
}, React.createElement(HiNestedSelect, _extends({
|
48
|
+
id: id,
|
49
|
+
name: name,
|
50
|
+
value: value,
|
51
|
+
options: options,
|
52
|
+
type: type,
|
53
|
+
multiple: multiple,
|
54
|
+
iconAll: iconAll,
|
55
|
+
checkbox: checkbox,
|
56
|
+
searchable: searchable,
|
57
|
+
translations: translations,
|
58
|
+
disabled: disabled,
|
59
|
+
error: error
|
60
|
+
}, others)));
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
HiNestedSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
66
|
+
/**
|
67
|
+
* Surcharge des styles
|
68
|
+
*/
|
69
|
+
className: PropTypes.string,
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Si `true`, l'input sera inactif.
|
73
|
+
*/
|
74
|
+
disabled: PropTypes.bool,
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Si `true`, le champs sera en erreur.
|
78
|
+
*/
|
79
|
+
error: PropTypes.bool,
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Texte de l'erreur
|
83
|
+
*/
|
84
|
+
errorText: PropTypes.string,
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
88
|
+
*/
|
89
|
+
helperIcon: PropTypes.bool,
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Texte de l'aide
|
93
|
+
*/
|
94
|
+
helperText: PropTypes.string,
|
95
|
+
|
96
|
+
/**
|
97
|
+
* id de l'élément input
|
98
|
+
*/
|
99
|
+
id: PropTypes.string.isRequired,
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Label du champs
|
103
|
+
*/
|
104
|
+
label: PropTypes.string,
|
105
|
+
|
106
|
+
/**
|
107
|
+
* true si champs obligatoire
|
108
|
+
*/
|
109
|
+
required: PropTypes.bool
|
110
|
+
} : {};
|
111
|
+
export default HiNestedSelectField;
|
@@ -23,7 +23,7 @@ export const styles = theme => ({
|
|
23
23
|
position: 'relative'
|
24
24
|
},
|
25
25
|
popper: {
|
26
|
-
|
26
|
+
width: '100%',
|
27
27
|
zIndex: 1200
|
28
28
|
},
|
29
29
|
paper: {
|
@@ -34,6 +34,12 @@ export const styles = theme => ({
|
|
34
34
|
labelIcon: {
|
35
35
|
marginRight: 10
|
36
36
|
},
|
37
|
+
labelImg: {
|
38
|
+
height: 18,
|
39
|
+
width: 'auto',
|
40
|
+
margin: '0 4px',
|
41
|
+
verticalAlign: 'middle'
|
42
|
+
},
|
37
43
|
selectIconLabel: _objectSpread({
|
38
44
|
whiteSpace: 'nowrap',
|
39
45
|
overflow: 'hidden',
|
@@ -42,6 +48,15 @@ export const styles = theme => ({
|
|
42
48
|
}, theme.typography.b1, {
|
43
49
|
display: 'inline-flex',
|
44
50
|
width: '100%'
|
51
|
+
}),
|
52
|
+
selectImgLabel: _objectSpread({
|
53
|
+
whiteSpace: 'nowrap',
|
54
|
+
overflow: 'hidden',
|
55
|
+
textOverflow: 'ellipsis',
|
56
|
+
paddingRight: 16
|
57
|
+
}, theme.typography.b1, {
|
58
|
+
display: 'inline-flex',
|
59
|
+
width: '100%'
|
45
60
|
})
|
46
61
|
});
|
47
62
|
/**
|
@@ -297,7 +312,7 @@ class HiSelect extends React.PureComponent {
|
|
297
312
|
inputValue = React.createElement("span", {
|
298
313
|
className: classes.selectIconLabel
|
299
314
|
}, React.createElement("img", {
|
300
|
-
className: classes.
|
315
|
+
className: classes.labelImg,
|
301
316
|
src: item.img,
|
302
317
|
alt: item.label
|
303
318
|
}), item.label);
|
@@ -324,6 +339,7 @@ class HiSelect extends React.PureComponent {
|
|
324
339
|
this.handleSearchReset = this.handleSearchReset.bind(this);
|
325
340
|
this.handleSelect = this.handleSelect.bind(this);
|
326
341
|
this.handleSuggestions = this.handleSuggestions.bind(this);
|
342
|
+
this.getInputElement = this.getInputElement.bind(this);
|
327
343
|
}
|
328
344
|
|
329
345
|
static getDerivedStateFromProps(nextProps, prevState) {
|
@@ -336,6 +352,14 @@ class HiSelect extends React.PureComponent {
|
|
336
352
|
return null;
|
337
353
|
}
|
338
354
|
|
355
|
+
getInputElement(el) {
|
356
|
+
this.searchField = el;
|
357
|
+
|
358
|
+
if (this.props.inputRef) {
|
359
|
+
this.props.inputRef(this.searchField);
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
339
363
|
render() {
|
340
364
|
const {
|
341
365
|
classes,
|
@@ -395,9 +419,7 @@ class HiSelect extends React.PureComponent {
|
|
395
419
|
}, !!searchable && React.createElement(HiInput, {
|
396
420
|
value: searchValue,
|
397
421
|
autoFocus: true,
|
398
|
-
inputRef:
|
399
|
-
this.searchField = el;
|
400
|
-
},
|
422
|
+
inputRef: this.getInputElement,
|
401
423
|
onKeyDown: this.handleKeyDownSearch,
|
402
424
|
onChange: this.handleSearch,
|
403
425
|
onReset: this.handleSearchReset,
|
@@ -441,6 +463,7 @@ class HiSelect extends React.PureComponent {
|
|
441
463
|
onSubmit: onSubmit,
|
442
464
|
onMouseEnter: this.props.onMouseEnter,
|
443
465
|
onMouseLeave: this.props.onMouseLeave,
|
466
|
+
onReset: this.props.onReset,
|
444
467
|
placeholder: placeholder
|
445
468
|
}, hiSelectInputProps, {
|
446
469
|
refElement: el => {
|
@@ -452,7 +475,6 @@ class HiSelect extends React.PureComponent {
|
|
452
475
|
anchorEl: this.inputEl,
|
453
476
|
placement: "bottom-start",
|
454
477
|
open: open,
|
455
|
-
eventsEnabled: open,
|
456
478
|
className: classes.popper,
|
457
479
|
disablePortal: true
|
458
480
|
}, content));
|
@@ -571,6 +593,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
571
593
|
*/
|
572
594
|
onMouseLeave: PropTypes.func,
|
573
595
|
|
596
|
+
/**
|
597
|
+
* Fonction de callback appelée lorsqu'on vide le champs
|
598
|
+
*/
|
599
|
+
onReset: PropTypes.func,
|
600
|
+
|
574
601
|
/**
|
575
602
|
* Fonction de callback appelée lorsque le scroll atteint le bas de la liste
|
576
603
|
*/
|