@hipay/hipay-material-ui 2.0.0-beta.41 → 2.0.0-beta.43
Sign up to get free protection for your applications and to get access to all the features.
- package/HiAppBar/HiAppBar.js +3 -20
- package/HiButton/HiButton.js +39 -15
- package/HiColoredLabel/HiColoredLabel.js +7 -2
- package/HiDatePicker/HiDatePicker.js +0 -2
- package/HiForm/HiInput.js +19 -0
- package/HiIcon/HiIcon.js +37 -31
- package/HiSelectNew/HiNestedSelect.js +44 -4
- package/HiSelectNew/HiSelect.js +12 -4
- package/HiSelectNew/HiSelectInput.js +50 -15
- package/HiSelectableList/HiSelectableListItem.js +8 -2
- package/es/HiAppBar/HiAppBar.js +3 -18
- package/es/HiButton/HiButton.js +43 -18
- package/es/HiColoredLabel/HiColoredLabel.js +8 -3
- package/es/HiDatePicker/HiDatePicker.js +0 -2
- package/es/HiForm/HiInput.js +18 -0
- package/es/HiIcon/HiIcon.js +37 -31
- package/es/HiSelectNew/HiNestedSelect.js +44 -6
- package/es/HiSelectNew/HiSelect.js +11 -4
- package/es/HiSelectNew/HiSelectInput.js +49 -15
- package/es/HiSelectableList/HiSelectableListItem.js +8 -2
- package/es/utils/helpers.js +22 -0
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +108 -50
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +24 -0
package/HiAppBar/HiAppBar.js
CHANGED
@@ -75,10 +75,6 @@ var _ref = _react.default.createElement(_HiIcon.default, {
|
|
75
75
|
icon: "keyboard_arrow_up"
|
76
76
|
});
|
77
77
|
|
78
|
-
var _ref2 = _react.default.createElement(_HiIcon.default, {
|
79
|
-
icon: "keyboard_arrow_down"
|
80
|
-
});
|
81
|
-
|
82
78
|
var HiAppBar =
|
83
79
|
/*#__PURE__*/
|
84
80
|
function (_React$Component) {
|
@@ -99,15 +95,7 @@ function (_React$Component) {
|
|
99
95
|
(0, _createClass2.default)(HiAppBar, [{
|
100
96
|
key: "handleCollapse",
|
101
97
|
value: function handleCollapse() {
|
102
|
-
|
103
|
-
this.props.onCollapse();
|
104
|
-
} else {
|
105
|
-
this.setState(function (prevState) {
|
106
|
-
return {
|
107
|
-
collapsed: !prevState.collapsed
|
108
|
-
};
|
109
|
-
});
|
110
|
-
}
|
98
|
+
this.props.onCollapse(!this.state.collapsed);
|
111
99
|
}
|
112
100
|
}, {
|
113
101
|
key: "render",
|
@@ -116,8 +104,7 @@ function (_React$Component) {
|
|
116
104
|
children = _this$props.children,
|
117
105
|
classes = _this$props.classes,
|
118
106
|
className = _this$props.className,
|
119
|
-
|
120
|
-
collapsed = _this$props$collapsed === void 0 ? this.state.collapsed : _this$props$collapsed,
|
107
|
+
collapsed = _this$props.collapsed,
|
121
108
|
focused = _this$props.focused,
|
122
109
|
hideable = _this$props.hideable,
|
123
110
|
position = _this$props.position,
|
@@ -137,11 +124,7 @@ function (_React$Component) {
|
|
137
124
|
onClick: this.handleCollapse,
|
138
125
|
color: "inherit",
|
139
126
|
className: classes.iconButton
|
140
|
-
}, _ref))))
|
141
|
-
onClick: this.handleCollapse,
|
142
|
-
color: "inherit",
|
143
|
-
className: classes.collapseButton
|
144
|
-
}, _ref2));
|
127
|
+
}, _ref)))));
|
145
128
|
}
|
146
129
|
}]);
|
147
130
|
return HiAppBar;
|
package/HiButton/HiButton.js
CHANGED
@@ -29,6 +29,12 @@ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
29
29
|
var styles = function styles(theme) {
|
30
30
|
return {
|
31
31
|
root: {},
|
32
|
+
flatNeutral: {
|
33
|
+
color: theme.palette.neutral.main,
|
34
|
+
'&$disabled': {
|
35
|
+
color: theme.palette.action.disabled
|
36
|
+
}
|
37
|
+
},
|
32
38
|
flatPositive: {
|
33
39
|
color: theme.palette.positive.main,
|
34
40
|
'&:hover': {
|
@@ -37,6 +43,9 @@ var styles = function styles(theme) {
|
|
37
43
|
'@media (hover: none)': {
|
38
44
|
backgroundColor: 'transparent'
|
39
45
|
}
|
46
|
+
},
|
47
|
+
'&$disabled': {
|
48
|
+
color: theme.palette.action.disabled
|
40
49
|
}
|
41
50
|
},
|
42
51
|
flatNegative: {
|
@@ -47,6 +56,9 @@ var styles = function styles(theme) {
|
|
47
56
|
'@media (hover: none)': {
|
48
57
|
backgroundColor: 'transparent'
|
49
58
|
}
|
59
|
+
},
|
60
|
+
'&$disabled': {
|
61
|
+
color: theme.palette.action.disabled
|
50
62
|
}
|
51
63
|
},
|
52
64
|
flatMiddle: {
|
@@ -57,16 +69,9 @@ var styles = function styles(theme) {
|
|
57
69
|
'@media (hover: none)': {
|
58
70
|
backgroundColor: 'transparent'
|
59
71
|
}
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
color: theme.palette.neutral.main,
|
64
|
-
'&:hover': {
|
65
|
-
backgroundColor: (0, _colorManipulator.fade)(theme.palette.neutral.main, theme.palette.action.hoverOpacity),
|
66
|
-
// Reset on touch devices, it doesn't add specificity
|
67
|
-
'@media (hover: none)': {
|
68
|
-
backgroundColor: 'transparent'
|
69
|
-
}
|
72
|
+
},
|
73
|
+
'&$disabled': {
|
74
|
+
color: theme.palette.action.disabled
|
70
75
|
}
|
71
76
|
},
|
72
77
|
|
@@ -80,6 +85,10 @@ var styles = function styles(theme) {
|
|
80
85
|
'@media (hover: none)': {
|
81
86
|
backgroundColor: theme.palette.positive.main
|
82
87
|
}
|
88
|
+
},
|
89
|
+
'&$disabled': {
|
90
|
+
color: theme.palette.neutral.contrastText,
|
91
|
+
backgroundColor: theme.palette.neutral.main
|
83
92
|
}
|
84
93
|
},
|
85
94
|
|
@@ -93,6 +102,10 @@ var styles = function styles(theme) {
|
|
93
102
|
'@media (hover: none)': {
|
94
103
|
backgroundColor: theme.palette.negative.main
|
95
104
|
}
|
105
|
+
},
|
106
|
+
'&$disabled': {
|
107
|
+
color: theme.palette.neutral.contrastText,
|
108
|
+
backgroundColor: theme.palette.neutral.main
|
96
109
|
}
|
97
110
|
},
|
98
111
|
|
@@ -106,6 +119,10 @@ var styles = function styles(theme) {
|
|
106
119
|
'@media (hover: none)': {
|
107
120
|
backgroundColor: theme.palette.middle.main
|
108
121
|
}
|
122
|
+
},
|
123
|
+
'&$disabled': {
|
124
|
+
color: theme.palette.neutral.contrastText,
|
125
|
+
backgroundColor: theme.palette.neutral.main
|
109
126
|
}
|
110
127
|
},
|
111
128
|
|
@@ -119,6 +136,10 @@ var styles = function styles(theme) {
|
|
119
136
|
'@media (hover: none)': {
|
120
137
|
backgroundColor: theme.palette.neutral.main
|
121
138
|
}
|
139
|
+
},
|
140
|
+
'&$disabled': {
|
141
|
+
color: theme.palette.neutral.contrastText,
|
142
|
+
backgroundColor: theme.palette.neutral.main
|
122
143
|
}
|
123
144
|
},
|
124
145
|
|
@@ -152,7 +173,8 @@ var styles = function styles(theme) {
|
|
152
173
|
'&:hover': {
|
153
174
|
border: "1px solid ".concat(theme.palette.neutral.main)
|
154
175
|
}
|
155
|
-
}
|
176
|
+
},
|
177
|
+
disabled: {}
|
156
178
|
};
|
157
179
|
};
|
158
180
|
|
@@ -166,18 +188,20 @@ function HiButton(props) {
|
|
166
188
|
className = props.className,
|
167
189
|
color = props.color,
|
168
190
|
variant = props.variant,
|
169
|
-
|
191
|
+
disabled = props.disabled,
|
192
|
+
other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "color", "variant", "disabled"]);
|
170
193
|
var hcolor = ['positive', 'negative', 'middle', 'neutral'].includes(color) ? 'inherit' : color;
|
171
194
|
var fab = variant === 'fab' || variant === 'extendedFab';
|
172
195
|
var contained = variant === 'contained' || variant === 'raised';
|
173
|
-
var buttonClassNames = (0, _classnames.default)(classes.root, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.flatPositive, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.flatNegative, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.flatMiddle, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.flatNeutral, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'neutral'), (0, _defineProperty2.default)(_classNames, classes.containedPositive, (contained || fab) && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.containedNegative, (contained || fab) && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.containedMiddle, (contained || fab) && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.containedNeutral, (contained || fab) && color === 'neutral'), (0, _defineProperty2.default)(_classNames, classes.outlinedPositive, variant === 'outlined' && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.outlinedNegative, variant === 'outlined' && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.outlinedMiddle, variant === 'outlined' && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.outlinedNeutral, variant === 'outlined' && color === 'neutral'), _classNames));
|
196
|
+
var buttonClassNames = (0, _classnames.default)(classes.root, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.flatPositive, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.flatNegative, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.flatMiddle, (variant === 'text' || variant === 'flat' || variant === 'outlined') && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.flatNeutral, (variant === 'text' || variant === 'flat' || variant === 'outlined') && (color === 'default' || color === 'neutral')), (0, _defineProperty2.default)(_classNames, classes.containedPositive, (contained || fab) && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.containedNegative, (contained || fab) && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.containedMiddle, (contained || fab) && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.containedNeutral, (contained || fab) && (color === 'default' || color === 'neutral')), (0, _defineProperty2.default)(_classNames, classes.outlinedPositive, variant === 'outlined' && color === 'positive'), (0, _defineProperty2.default)(_classNames, classes.outlinedNegative, variant === 'outlined' && color === 'negative'), (0, _defineProperty2.default)(_classNames, classes.outlinedMiddle, variant === 'outlined' && color === 'middle'), (0, _defineProperty2.default)(_classNames, classes.outlinedNeutral, variant === 'outlined' && (color === 'default' || color === 'neutral')), (0, _defineProperty2.default)(_classNames, classes.disabled, disabled), _classNames));
|
174
197
|
return _react.default.createElement(_Button.default, (0, _extends2.default)({
|
175
198
|
className: className,
|
176
199
|
classes: {
|
177
200
|
root: buttonClassNames
|
178
201
|
},
|
179
202
|
color: hcolor,
|
180
|
-
variant: variant
|
203
|
+
variant: variant,
|
204
|
+
disabled: disabled
|
181
205
|
}, other), children);
|
182
206
|
}
|
183
207
|
|
@@ -203,7 +227,7 @@ HiButton.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
203
227
|
variant: _propTypes.default.oneOf(['text', 'flat', 'outlined', 'contained', 'raised', 'fab', 'extendedFab'])
|
204
228
|
} : {};
|
205
229
|
HiButton.defaultProps = {
|
206
|
-
color: '
|
230
|
+
color: 'neutral',
|
207
231
|
variant: 'text'
|
208
232
|
};
|
209
233
|
|
@@ -27,7 +27,7 @@ var _colorManipulator = require("../styles/colorManipulator");
|
|
27
27
|
|
28
28
|
var styles = function styles(theme) {
|
29
29
|
return {
|
30
|
-
root: (0, _extends2.default)({}, theme.typography.
|
30
|
+
root: (0, _extends2.default)({}, theme.typography.b1, {
|
31
31
|
display: 'inline-block',
|
32
32
|
alignItems: 'baseline',
|
33
33
|
maxWidth: '100%',
|
@@ -147,7 +147,12 @@ function HiColoredLabel(props) {
|
|
147
147
|
}, fontWeight && {
|
148
148
|
fontWeight: fontWeight
|
149
149
|
})
|
150
|
-
}, other
|
150
|
+
}, other, {
|
151
|
+
// eslint-disable-next-line react/no-danger
|
152
|
+
dangerouslySetInnerHTML: {
|
153
|
+
__html: (0, _helpers.escapeHTML)(label)
|
154
|
+
}
|
155
|
+
}));
|
151
156
|
}
|
152
157
|
|
153
158
|
HiColoredLabel.propTypes = process.env.NODE_ENV !== "production" ? {
|
package/HiForm/HiInput.js
CHANGED
@@ -219,6 +219,10 @@ function (_React$PureComponent) {
|
|
219
219
|
// Si on click sur un élément de HiInput, on garde le focus
|
220
220
|
// Par exemple sur l'icone reset
|
221
221
|
if (event.relatedTarget && this.overlayNode && this.overlayNode.contains(event.relatedTarget)) {
|
222
|
+
if (this.endAdornmentNode.contains(event.relatedTarget) && this.props.onBlur) {
|
223
|
+
this.props.onBlur(event);
|
224
|
+
}
|
225
|
+
|
222
226
|
event.stopPropagation();
|
223
227
|
} else {
|
224
228
|
this.setState({
|
@@ -390,6 +394,15 @@ function (_React$PureComponent) {
|
|
390
394
|
}
|
391
395
|
}));
|
392
396
|
}
|
397
|
+
}], [{
|
398
|
+
key: "getDerivedStateFromProps",
|
399
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
400
|
+
if (typeof nextProps.focused !== 'undefined' && nextProps.focused !== prevState.focused) {
|
401
|
+
return {
|
402
|
+
focused: nextProps.focused
|
403
|
+
};
|
404
|
+
}
|
405
|
+
}
|
393
406
|
}]);
|
394
407
|
return HiInput;
|
395
408
|
}(_react.default.PureComponent);
|
@@ -445,6 +458,12 @@ HiInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
445
458
|
*/
|
446
459
|
error: _propTypes.default.bool,
|
447
460
|
|
461
|
+
/**
|
462
|
+
* Force le focus de l'input et surcharge le comportement par défaut
|
463
|
+
* où le focus est géré dans le state.
|
464
|
+
*/
|
465
|
+
focused: _propTypes.default.bool,
|
466
|
+
|
448
467
|
/**
|
449
468
|
* Utile pour surcharger les classes de l'input
|
450
469
|
*/
|
package/HiIcon/HiIcon.js
CHANGED
@@ -34,42 +34,48 @@ var mdi = _interopRequireWildcard(require("mdi-material-ui"));
|
|
34
34
|
var styles = function styles(theme) {
|
35
35
|
return {
|
36
36
|
/* Styles applied to the root element. */
|
37
|
-
root: {
|
37
|
+
root: {
|
38
|
+
/* Styles applied to the root element if `color="primary"`. */
|
39
|
+
'&$colorPrimary': {
|
40
|
+
color: theme.palette.primary.main
|
41
|
+
},
|
42
|
+
|
43
|
+
/* Styles applied to the root element if `color="secondary"`. */
|
44
|
+
'&$colorSecondary': {
|
45
|
+
color: theme.palette.secondary.main
|
46
|
+
},
|
47
|
+
|
48
|
+
/* Styles applied to the root element if `color="positive"`. */
|
49
|
+
'&$colorPositive': {
|
50
|
+
color: theme.palette.positive.main
|
51
|
+
},
|
52
|
+
|
53
|
+
/* Styles applied to the root element if `color="negative"`. */
|
54
|
+
'&$colorNegative': {
|
55
|
+
color: theme.palette.negative.main
|
56
|
+
},
|
57
|
+
|
58
|
+
/* Styles applied to the root element if `color="middle"`. */
|
59
|
+
'&$colorMiddle': {
|
60
|
+
color: theme.palette.middle.main
|
61
|
+
},
|
62
|
+
|
63
|
+
/* Styles applied to the root element if `color="neutral"`. */
|
64
|
+
'&$colorNeutral': {
|
65
|
+
color: theme.palette.neutral.main
|
66
|
+
}
|
67
|
+
},
|
38
68
|
|
39
69
|
/* Styles applied to the root element. */
|
40
70
|
faIcon: {
|
41
71
|
fontSize: 20
|
42
72
|
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
},
|
48
|
-
|
49
|
-
/* Styles applied to the root element if `color="secondary"`. */
|
50
|
-
colorSecondary: {
|
51
|
-
color: theme.palette.secondary.main
|
52
|
-
},
|
53
|
-
|
54
|
-
/* Styles applied to the root element if `color="positive"`. */
|
55
|
-
colorPositive: {
|
56
|
-
color: theme.palette.positive.main
|
57
|
-
},
|
58
|
-
|
59
|
-
/* Styles applied to the root element if `color="negative"`. */
|
60
|
-
colorNegative: {
|
61
|
-
color: theme.palette.negative.main
|
62
|
-
},
|
63
|
-
|
64
|
-
/* Styles applied to the root element if `color="middle"`. */
|
65
|
-
colorMiddle: {
|
66
|
-
color: theme.palette.middle.main
|
67
|
-
},
|
68
|
-
|
69
|
-
/* Styles applied to the root element if `color="neutral"`. */
|
70
|
-
colorNeutral: {
|
71
|
-
color: theme.palette.neutral.main
|
72
|
-
}
|
73
|
+
colorPrimary: {},
|
74
|
+
colorSecondary: {},
|
75
|
+
colorPositive: {},
|
76
|
+
colorNegative: {},
|
77
|
+
colorMiddle: {},
|
78
|
+
colorNeutral: {}
|
73
79
|
};
|
74
80
|
};
|
75
81
|
|
@@ -35,6 +35,8 @@ var _HiIcon = _interopRequireDefault(require("../HiIcon"));
|
|
35
35
|
|
36
36
|
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
37
37
|
|
38
|
+
var _helpers = require("../utils/helpers");
|
39
|
+
|
38
40
|
// @inheritedComponent HiSelect
|
39
41
|
|
40
42
|
/**
|
@@ -86,6 +88,8 @@ function findFinalItemRecursively(itemList, searchId) {
|
|
86
88
|
* @param visibleParent - visibility of the list parent item (default false)
|
87
89
|
* @param pinnedParent - parent will be displayed as pinned items
|
88
90
|
* @param disabledParent - parent will not be selectable
|
91
|
+
* @param nbChildrenAsInfo - Show children number as info
|
92
|
+
* @param translations - Translations
|
89
93
|
* @returns {*}
|
90
94
|
*/
|
91
95
|
|
@@ -96,12 +100,14 @@ function buildFilteredItemList(itemList) {
|
|
96
100
|
var visibleParent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
97
101
|
var pinnedParent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
98
102
|
var disabledParent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
103
|
+
var nbChildrenAsInfo = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
104
|
+
var translations = arguments.length > 7 ? arguments[7] : undefined;
|
99
105
|
return itemList.reduce(function (_ref, item) {
|
100
106
|
var memoItemList = _ref.l,
|
101
107
|
memoSelected = _ref.s,
|
102
108
|
memoUnselected = _ref.u,
|
103
109
|
memoVisible = _ref.v;
|
104
|
-
var itemVisible = searchValue === '' || item.label.toString().toLowerCase().search(searchValue.toLowerCase()) !== -1; // Parent item
|
110
|
+
var itemVisible = searchValue === '' || (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(searchValue.toLowerCase())) !== -1; // Parent item
|
105
111
|
|
106
112
|
if (item.children) {
|
107
113
|
var _buildFilteredItemLis = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent),
|
@@ -110,6 +116,10 @@ function buildFilteredItemList(itemList) {
|
|
110
116
|
unselected = _buildFilteredItemLis.u,
|
111
117
|
visible = _buildFilteredItemLis.v;
|
112
118
|
|
119
|
+
if (nbChildrenAsInfo) {
|
120
|
+
item.info = translations.n_children.replace('%s', item.children.length);
|
121
|
+
}
|
122
|
+
|
113
123
|
return {
|
114
124
|
l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({}, item, disabledParent && {
|
115
125
|
disabled: true,
|
@@ -161,7 +171,31 @@ var styles = function styles(theme) {
|
|
161
171
|
borderRadius: '0px 2px',
|
162
172
|
maxHeight: 480,
|
163
173
|
transition: 'none !important'
|
164
|
-
}
|
174
|
+
},
|
175
|
+
labelImg: {
|
176
|
+
height: 18,
|
177
|
+
width: 'auto',
|
178
|
+
margin: '0 4px',
|
179
|
+
verticalAlign: 'middle'
|
180
|
+
},
|
181
|
+
selectIconLabel: (0, _extends2.default)({
|
182
|
+
whiteSpace: 'nowrap',
|
183
|
+
overflow: 'hidden',
|
184
|
+
textOverflow: 'ellipsis',
|
185
|
+
paddingRight: 16
|
186
|
+
}, theme.typography.b1, {
|
187
|
+
display: 'inline-flex',
|
188
|
+
width: '100%'
|
189
|
+
}),
|
190
|
+
selectImgLabel: (0, _extends2.default)({
|
191
|
+
whiteSpace: 'nowrap',
|
192
|
+
overflow: 'hidden',
|
193
|
+
textOverflow: 'ellipsis',
|
194
|
+
paddingRight: 16
|
195
|
+
}, theme.typography.b1, {
|
196
|
+
display: 'inline-flex',
|
197
|
+
width: '100%'
|
198
|
+
})
|
165
199
|
};
|
166
200
|
};
|
167
201
|
/**
|
@@ -249,10 +283,11 @@ function (_React$PureComponent) {
|
|
249
283
|
hasAll = _this$props2.hasAll,
|
250
284
|
iconAll = _this$props2.iconAll,
|
251
285
|
multiple = _this$props2.multiple,
|
286
|
+
nbChildrenAsInfo = _this$props2.nbChildrenAsInfo,
|
252
287
|
pinnedParent = _this$props2.pinnedParent,
|
253
288
|
translations = _this$props2.translations; // build item list
|
254
289
|
|
255
|
-
var _buildFilteredItemLis2 = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple),
|
290
|
+
var _buildFilteredItemLis2 = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations),
|
256
291
|
filteredItemList = _buildFilteredItemLis2.l,
|
257
292
|
allSelected = _buildFilteredItemLis2.s,
|
258
293
|
allUnselected = _buildFilteredItemLis2.u,
|
@@ -389,7 +424,7 @@ HiNestedSelect.defaultProps = {
|
|
389
424
|
search: 'Search',
|
390
425
|
n_items_selected: '%s items selected',
|
391
426
|
one_item_selected: '%s item selected',
|
392
|
-
n_children: '%s
|
427
|
+
n_children: '%s',
|
393
428
|
one_child: '%s item'
|
394
429
|
}
|
395
430
|
};
|
@@ -434,6 +469,11 @@ HiNestedSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
434
469
|
*/
|
435
470
|
name: _propTypes.default.string.isRequired,
|
436
471
|
|
472
|
+
/**
|
473
|
+
* Définit si l'on doit afficher le nombre d'enfants du parent dans son champ info
|
474
|
+
*/
|
475
|
+
nbChildrenAsInfo: _propTypes.default.bool,
|
476
|
+
|
437
477
|
/**
|
438
478
|
* Fonction de callback qui renvoit la/les valeurs sélectionnées
|
439
479
|
*
|
package/HiSelectNew/HiSelect.js
CHANGED
@@ -62,7 +62,7 @@ var styles = function styles(theme) {
|
|
62
62
|
position: 'relative'
|
63
63
|
},
|
64
64
|
popper: {
|
65
|
-
width: '100%',
|
65
|
+
width: '100% !important',
|
66
66
|
zIndex: 1200
|
67
67
|
},
|
68
68
|
paper: {
|
@@ -193,7 +193,9 @@ function (_React$PureComponent) {
|
|
193
193
|
|
194
194
|
if (_this.overlay && (key === 'down' || key === 'up')) {
|
195
195
|
_this.focusOnFirstItem();
|
196
|
-
} else if (_this.overlay && key === 'esc') {
|
196
|
+
} else if (_this.overlay && key === 'esc' || key === 'enter') {
|
197
|
+
event.preventDefault();
|
198
|
+
|
197
199
|
_this.handleClose();
|
198
200
|
}
|
199
201
|
};
|
@@ -336,8 +338,14 @@ function (_React$PureComponent) {
|
|
336
338
|
hideCheckbox: true,
|
337
339
|
label: 'loading'
|
338
340
|
}] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
|
339
|
-
return item.label && item.label.toString().toLowerCase().search(search.toLowerCase()) !== -1;
|
340
|
-
})) : (0, _toConsumableArray2.default)(
|
341
|
+
return item.label && (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(search.toLowerCase())) !== -1;
|
342
|
+
})) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
|
343
|
+
id: '_all',
|
344
|
+
label: _this.props.translations.all
|
345
|
+
}, _this.props.iconAll && {
|
346
|
+
type: 'icon',
|
347
|
+
icon: _this.props.iconAll
|
348
|
+
})] : []).concat((0, _toConsumableArray2.default)(options))));
|
341
349
|
return {
|
342
350
|
itemList: itemList,
|
343
351
|
inputValue: _this.buildInputValue(options, value, loading)
|
@@ -181,14 +181,54 @@ function (_React$PureComponent) {
|
|
181
181
|
}
|
182
182
|
};
|
183
183
|
|
184
|
+
_this.handleKeyDownReset = function (event) {
|
185
|
+
var key = (0, _keycode.default)(event);
|
186
|
+
|
187
|
+
if (key === 'enter' || key === 'space') {
|
188
|
+
_this.handleReset(event);
|
189
|
+
|
190
|
+
event.stopPropagation();
|
191
|
+
event.preventDefault();
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
184
195
|
_this.handleClick = function (event) {
|
185
196
|
if ((!_this.resetIcon || !_this.resetIcon.contains(event.target)) && _this.props.onClick) {
|
186
197
|
_this.props.onClick(event);
|
187
198
|
}
|
188
199
|
};
|
189
200
|
|
201
|
+
_this.handleReset = function (event) {
|
202
|
+
_this.props.onReset(event);
|
203
|
+
|
204
|
+
if (_this.input) {
|
205
|
+
_this.input.focus();
|
206
|
+
}
|
207
|
+
};
|
208
|
+
|
209
|
+
_this.handleBlur = function (event) {
|
210
|
+
if ((!_this.input || !_this.input.contains(event.relatedTarget)) && _this.props.onBlur) {
|
211
|
+
_this.props.onBlur(event);
|
212
|
+
} else {
|
213
|
+
if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
|
214
|
+
_this.input.focus();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
219
|
+
_this.handleRef = function (el) {
|
220
|
+
_this.input = el;
|
221
|
+
|
222
|
+
if (_this.props.refElement) {
|
223
|
+
_this.props.refElement(el);
|
224
|
+
}
|
225
|
+
};
|
226
|
+
|
190
227
|
_this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
191
228
|
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
229
|
+
_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)));
|
231
|
+
_this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
192
232
|
return _this;
|
193
233
|
}
|
194
234
|
|
@@ -210,9 +250,7 @@ function (_React$PureComponent) {
|
|
210
250
|
focused = _this$props.focused,
|
211
251
|
error = _this$props.error,
|
212
252
|
id = _this$props.id,
|
213
|
-
placeholder = _this$props.placeholder
|
214
|
-
refElement = _this$props.refElement,
|
215
|
-
theme = _this$props.theme; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
253
|
+
placeholder = _this$props.placeholder; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
216
254
|
|
217
255
|
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));
|
218
256
|
var iconClass = (0, _classnames.default)(classes.icon, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, classes.iconOpen, open), (0, _defineProperty2.default)(_classNames2, classes.iconClose, !open), _classNames2));
|
@@ -227,9 +265,7 @@ function (_React$PureComponent) {
|
|
227
265
|
onBlur: this.props.onBlur,
|
228
266
|
role: "button",
|
229
267
|
tabIndex: "0",
|
230
|
-
ref:
|
231
|
-
if (refElement) refElement(el);
|
232
|
-
}
|
268
|
+
ref: this.handleRef
|
233
269
|
}, _react.default.createElement("span", {
|
234
270
|
className: (0, _classnames.default)(classes.label, (0, _defineProperty2.default)({}, classes.placeholder, value === undefined))
|
235
271
|
}, value || placeholder), _react.default.createElement(_ArrowDropDown.default, {
|
@@ -243,10 +279,8 @@ function (_React$PureComponent) {
|
|
243
279
|
onMouseLeave: this.props.onMouseLeave,
|
244
280
|
onKeyDown: this.handleKeyDown,
|
245
281
|
onFocus: this.props.onFocus,
|
246
|
-
onBlur: this.
|
247
|
-
buttonRef:
|
248
|
-
if (refElement) refElement(el);
|
249
|
-
}
|
282
|
+
onBlur: this.handleBlur,
|
283
|
+
buttonRef: this.handleRef
|
250
284
|
}, _react.default.createElement("span", {
|
251
285
|
className: (0, _classnames.default)(classes.label, (0, _defineProperty2.default)({}, classes.placeholder, value === undefined))
|
252
286
|
}, value || placeholder), onReset && focused && _react.default.createElement("div", {
|
@@ -255,9 +289,11 @@ function (_React$PureComponent) {
|
|
255
289
|
}
|
256
290
|
}, _react.default.createElement(_HiIcon.default, {
|
257
291
|
icon: "close",
|
258
|
-
size:
|
259
|
-
color:
|
260
|
-
onClick:
|
292
|
+
size: 20,
|
293
|
+
color: "neutral",
|
294
|
+
onClick: this.handleReset,
|
295
|
+
onKeyDown: this.handleKeyDownReset,
|
296
|
+
tabIndex: 0
|
261
297
|
})), _react.default.createElement(_Icon.default, {
|
262
298
|
classes: {
|
263
299
|
root: iconClass
|
@@ -370,8 +406,7 @@ HiSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
370
406
|
|
371
407
|
var _default = (0, _withStyles.default)(styles, {
|
372
408
|
hiComponent: true,
|
373
|
-
name: 'HmuiHiSelectInput'
|
374
|
-
withTheme: true
|
409
|
+
name: 'HmuiHiSelectInput'
|
375
410
|
})(HiSelectInput);
|
376
411
|
|
377
412
|
exports.default = _default;
|
@@ -111,7 +111,10 @@ var styles = function styles(theme) {
|
|
111
111
|
}, theme.typography.b1, {
|
112
112
|
fontWeight: 'inherit',
|
113
113
|
width: '100%',
|
114
|
-
padding: '5px 0'
|
114
|
+
padding: '5px 0',
|
115
|
+
'& strong': {
|
116
|
+
fontWeight: theme.typography.fontWeightMedium
|
117
|
+
}
|
115
118
|
}),
|
116
119
|
label: {
|
117
120
|
display: 'inline-block',
|
@@ -259,6 +262,7 @@ function (_React$Component) {
|
|
259
262
|
hideCheckbox = _this$props2.hideCheckbox,
|
260
263
|
onSelect = _this$props2.onSelect,
|
261
264
|
indeterminate = _this$props2.indeterminate,
|
265
|
+
indeterminateIcon = _this$props2.indeterminateIcon,
|
262
266
|
icon = _this$props2.icon,
|
263
267
|
id = _this$props2.id,
|
264
268
|
img = _this$props2.img,
|
@@ -317,7 +321,8 @@ function (_React$Component) {
|
|
317
321
|
,
|
318
322
|
disabled: disabled,
|
319
323
|
icon: displayedIcon,
|
320
|
-
indeterminate: indeterminate
|
324
|
+
indeterminate: indeterminate,
|
325
|
+
indeterminateIcon: indeterminateIcon
|
321
326
|
}), _react.default.createElement("div", {
|
322
327
|
className: (0, _classnames.default)(classes.listItemContent, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, classes.centered, centered), (0, _defineProperty2.default)(_classNames2, classes.primaryHighlight, type === 'primary-highlight'), _classNames2)),
|
323
328
|
"data-id": id
|
@@ -351,6 +356,7 @@ HiSelectableListItem.defaultProps = {
|
|
351
356
|
hideCheckbox: false,
|
352
357
|
hoverIcon: 'check_box_outline_blank',
|
353
358
|
checkedIcon: 'check_box',
|
359
|
+
indeterminateIcon: 'indeterminate_check_box',
|
354
360
|
indeterminate: false,
|
355
361
|
level: 0,
|
356
362
|
paddingLeft: 4,
|