@hipay/hipay-material-ui 2.0.0-beta.57 → 2.0.0-beta.59
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 +117 -0
- package/HiAlertModal/HiAlertModal.js +56 -13
- package/HiColoredLabel/HiColoredLabel.js +16 -4
- package/HiForm/HiFormControl.js +2 -4
- package/HiForm/HiInput.js +29 -4
- package/HiForm/HiUploadField.js +2 -1
- package/HiSelect/HiSelect.js +6 -5
- package/HiSelect/HiSuggestSelect.js +5 -4
- package/HiSelect/SelectInput.js +1 -0
- package/HiSelectNew/HiNestedSelect.js +20 -6
- package/HiSelectNew/HiNestedSelectContent.js +20 -6
- package/HiSelectNew/HiSelect.js +104 -32
- package/HiSelectNew/HiSelectContent.js +16 -4
- package/HiSelectNew/HiSelectInput.js +10 -3
- package/HiSelectableList/HiSelectableList.js +2 -35
- package/HiSelectableList/HiSelectableListItem.js +6 -4
- package/es/HiAlertModal/HiAlertModal.js +55 -13
- package/es/HiColoredLabel/HiColoredLabel.js +21 -4
- package/es/HiForm/HiFormControl.js +2 -4
- package/es/HiForm/HiInput.js +29 -4
- package/es/HiForm/HiUploadField.js +2 -1
- package/es/HiSelect/HiSelect.js +6 -5
- package/es/HiSelect/HiSuggestSelect.js +5 -4
- package/es/HiSelect/SelectInput.js +1 -0
- package/es/HiSelectNew/HiNestedSelect.js +17 -7
- package/es/HiSelectNew/HiNestedSelectContent.js +16 -6
- package/es/HiSelectNew/HiSelect.js +106 -31
- package/es/HiSelectNew/HiSelectContent.js +11 -2
- package/es/HiSelectNew/HiSelectInput.js +10 -3
- package/es/HiSelectableList/HiSelectableList.js +3 -29
- package/es/HiSelectableList/HiSelectableListItem.js +6 -4
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +15551 -16279
- package/umd/hipay-material-ui.production.min.js +2 -2
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getRecursiveFinalItemIdList = getRecursiveFinalItemIdList;
|
|
9
9
|
exports.findFinalItemRecursively = findFinalItemRecursively;
|
|
10
|
-
exports.default = void 0;
|
|
10
|
+
exports.default = exports.filterValue = void 0;
|
|
11
11
|
|
|
12
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
13
|
|
|
@@ -72,6 +72,10 @@ function findFinalItemRecursively(itemList, searchId) {
|
|
|
72
72
|
});
|
|
73
73
|
return foundItem;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
var filterValue = function filterValue(item, searchValue) {
|
|
77
|
+
return searchValue === '' || (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(searchValue.toLowerCase())) !== -1;
|
|
78
|
+
};
|
|
75
79
|
/**
|
|
76
80
|
* Build item list by settings item props relative to the nested parent/child situation
|
|
77
81
|
* Reduce the item list to build specified items (displayed, pinned, disabled, selected, indeterminate)
|
|
@@ -90,6 +94,8 @@ function findFinalItemRecursively(itemList, searchId) {
|
|
|
90
94
|
*/
|
|
91
95
|
|
|
92
96
|
|
|
97
|
+
exports.filterValue = filterValue;
|
|
98
|
+
|
|
93
99
|
function buildFilteredItemList(itemList) {
|
|
94
100
|
var selectedItemIdList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
95
101
|
var searchValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
@@ -98,15 +104,16 @@ function buildFilteredItemList(itemList) {
|
|
|
98
104
|
var disabledParent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
99
105
|
var nbChildrenAsInfo = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
100
106
|
var translations = arguments.length > 7 ? arguments[7] : undefined;
|
|
107
|
+
var filterFunc = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : filterValue;
|
|
101
108
|
return itemList.reduce(function (_ref, item) {
|
|
102
109
|
var memoItemList = _ref.l,
|
|
103
110
|
memoSelected = _ref.s,
|
|
104
111
|
memoUnselected = _ref.u,
|
|
105
112
|
memoVisible = _ref.v;
|
|
106
|
-
var itemVisible =
|
|
113
|
+
var itemVisible = filterFunc(item, searchValue); // Parent item
|
|
107
114
|
|
|
108
115
|
if (item.children) {
|
|
109
|
-
var _buildFilteredItemLis = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent),
|
|
116
|
+
var _buildFilteredItemLis = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent, nbChildrenAsInfo, translations, filterFunc),
|
|
110
117
|
customizedChildren = _buildFilteredItemLis.l,
|
|
111
118
|
selected = _buildFilteredItemLis.s,
|
|
112
119
|
unselected = _buildFilteredItemLis.u,
|
|
@@ -241,9 +248,10 @@ function (_React$PureComponent) {
|
|
|
241
248
|
multiple = _this$props2.multiple,
|
|
242
249
|
nbChildrenAsInfo = _this$props2.nbChildrenAsInfo,
|
|
243
250
|
pinnedParent = _this$props2.pinnedParent,
|
|
244
|
-
translations = _this$props2.translations
|
|
251
|
+
translations = _this$props2.translations,
|
|
252
|
+
filterFunc = _this$props2.filterFunc; // build item list
|
|
245
253
|
|
|
246
|
-
var _buildFilteredItemLis2 = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations),
|
|
254
|
+
var _buildFilteredItemLis2 = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations, filterFunc),
|
|
247
255
|
filteredItemList = _buildFilteredItemLis2.l,
|
|
248
256
|
allSelected = _buildFilteredItemLis2.s,
|
|
249
257
|
allUnselected = _buildFilteredItemLis2.u,
|
|
@@ -334,7 +342,8 @@ HiNestedSelectContent.defaultProps = {
|
|
|
334
342
|
search: 'Search',
|
|
335
343
|
n_children: '%s',
|
|
336
344
|
one_child: '%s item'
|
|
337
|
-
}
|
|
345
|
+
},
|
|
346
|
+
filterFunc: filterValue
|
|
338
347
|
};
|
|
339
348
|
HiNestedSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
340
349
|
/**
|
|
@@ -347,6 +356,11 @@ HiNestedSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
347
356
|
*/
|
|
348
357
|
disabledParent: _propTypes.default.bool,
|
|
349
358
|
|
|
359
|
+
/*
|
|
360
|
+
* Fonction de filtrage custom
|
|
361
|
+
*/
|
|
362
|
+
filterFunc: _propTypes.default.func,
|
|
363
|
+
|
|
350
364
|
/**
|
|
351
365
|
* Affiche l'élément 'All'
|
|
352
366
|
*/
|
package/HiSelectNew/HiSelect.js
CHANGED
|
@@ -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"));
|
|
@@ -112,6 +110,12 @@ var styles = function styles(theme) {
|
|
|
112
110
|
}
|
|
113
111
|
};
|
|
114
112
|
};
|
|
113
|
+
|
|
114
|
+
exports.styles = styles;
|
|
115
|
+
|
|
116
|
+
function filterValue(item, search) {
|
|
117
|
+
return search === '' || (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(search.toLowerCase())) !== -1;
|
|
118
|
+
}
|
|
115
119
|
/**
|
|
116
120
|
*
|
|
117
121
|
* Utilisé pour tous types de selects dans les formulaires.
|
|
@@ -128,8 +132,6 @@ var styles = function styles(theme) {
|
|
|
128
132
|
*/
|
|
129
133
|
|
|
130
134
|
|
|
131
|
-
exports.styles = styles;
|
|
132
|
-
|
|
133
135
|
var HiSelect =
|
|
134
136
|
/*#__PURE__*/
|
|
135
137
|
function (_React$PureComponent) {
|
|
@@ -154,7 +156,7 @@ function (_React$PureComponent) {
|
|
|
154
156
|
hideCheckbox: true,
|
|
155
157
|
label: 'loading'
|
|
156
158
|
}] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
|
|
157
|
-
return
|
|
159
|
+
return _this.props.filterFunc(item, search);
|
|
158
160
|
})) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
|
|
159
161
|
id: '_all',
|
|
160
162
|
label: _this.props.translations.all
|
|
@@ -224,11 +226,13 @@ function (_React$PureComponent) {
|
|
|
224
226
|
};
|
|
225
227
|
|
|
226
228
|
_this.focusOnFirstItem = function () {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
if (_this.overlay && _this.overlay.getElementsByTagName('li')[0]) {
|
|
230
|
+
setTimeout(function () {
|
|
231
|
+
var item = _this.overlay.getElementsByTagName('li')[0];
|
|
232
|
+
|
|
233
|
+
item.focus();
|
|
234
|
+
}, 1);
|
|
235
|
+
}
|
|
232
236
|
};
|
|
233
237
|
|
|
234
238
|
_this.getInputElement = function (el) {
|
|
@@ -267,21 +271,22 @@ function (_React$PureComponent) {
|
|
|
267
271
|
};
|
|
268
272
|
|
|
269
273
|
_this.focusOnSelectedItem = function (selectedValue) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
274
|
+
if (_this.overlay && _this.overlay.getElementsByTagName('li')[0]) {
|
|
275
|
+
setTimeout(function () {
|
|
276
|
+
// On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
|
|
277
|
+
var item = _this.overlay.getElementsByTagName('li')[0];
|
|
278
|
+
|
|
279
|
+
if (selectedValue && typeof selectedValue === 'string') {
|
|
280
|
+
item = _this.overlay.getElementsByTagName('li')[selectedValue];
|
|
281
|
+
} else if (selectedValue && typeof selectedValue === 'number') {
|
|
282
|
+
item = _this.overlay.getElementsByTagName('li')[selectedValue - 1];
|
|
283
|
+
}
|
|
280
284
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
+
if (item) {
|
|
286
|
+
item.focus();
|
|
287
|
+
}
|
|
288
|
+
}, 1);
|
|
289
|
+
}
|
|
285
290
|
};
|
|
286
291
|
|
|
287
292
|
_this.handleClickAway = function (event) {
|
|
@@ -313,6 +318,18 @@ function (_React$PureComponent) {
|
|
|
313
318
|
});
|
|
314
319
|
};
|
|
315
320
|
|
|
321
|
+
_this.handleKeyDownInput = function (event) {
|
|
322
|
+
var key = (0, _keycode.default)(event);
|
|
323
|
+
|
|
324
|
+
if (key === 'down' || key === 'up') {
|
|
325
|
+
_this.handleClick();
|
|
326
|
+
} else if (key === 'enter' && _this.props.onSubmit) {
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
|
|
329
|
+
_this.props.onSubmit(event);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
316
333
|
_this.handleKeyDown = function (event) {
|
|
317
334
|
var nextItem;
|
|
318
335
|
var key = (0, _keycode.default)(event);
|
|
@@ -323,6 +340,13 @@ function (_React$PureComponent) {
|
|
|
323
340
|
} else if (key === 'up') {
|
|
324
341
|
event.preventDefault();
|
|
325
342
|
nextItem = (0, _helpers.getNextItemSelectable)(document.activeElement, 'up');
|
|
343
|
+
} else if (key === 'tab' || key === 'esc') {
|
|
344
|
+
_this.setState({
|
|
345
|
+
open: false
|
|
346
|
+
});
|
|
347
|
+
} else if (key === 'space') {
|
|
348
|
+
// Cancel scroll
|
|
349
|
+
event.preventDefault();
|
|
326
350
|
}
|
|
327
351
|
|
|
328
352
|
if (nextItem) {
|
|
@@ -330,21 +354,58 @@ function (_React$PureComponent) {
|
|
|
330
354
|
}
|
|
331
355
|
};
|
|
332
356
|
|
|
357
|
+
_this.getItemById = function (id) {
|
|
358
|
+
var item;
|
|
359
|
+
|
|
360
|
+
if (_this.props.hasAll && String(id) === '_all') {
|
|
361
|
+
return {
|
|
362
|
+
id: '_all'
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
for (var i = 0; i < _this.props.options.length; i += 1) {
|
|
367
|
+
var elem = _this.props.options[i];
|
|
368
|
+
|
|
369
|
+
if (String(elem.id) === String(id)) {
|
|
370
|
+
item = elem;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (elem.children) {
|
|
375
|
+
for (var j = 0; j < elem.children.length; j += 1) {
|
|
376
|
+
if (String(elem.children[j].id) === String(id)) {
|
|
377
|
+
item = elem.children[j];
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return item;
|
|
385
|
+
};
|
|
386
|
+
|
|
333
387
|
_this.handleKeyUp = function (event) {
|
|
334
388
|
var key = (0, _keycode.default)(event);
|
|
335
389
|
|
|
336
|
-
if (key === '
|
|
390
|
+
if (key === 'esc') {
|
|
337
391
|
_this.setState({
|
|
338
392
|
open: false
|
|
339
393
|
});
|
|
340
394
|
} else if (key === 'space' || key === 'enter' && !_this.props.multiple) {
|
|
341
395
|
event.preventDefault();
|
|
342
396
|
|
|
343
|
-
var item = _this.
|
|
344
|
-
return String(elem.id) === event.target.id;
|
|
345
|
-
});
|
|
397
|
+
var item = _this.getItemById(event.target.id);
|
|
346
398
|
|
|
347
|
-
|
|
399
|
+
if (item) {
|
|
400
|
+
// Select for nested select
|
|
401
|
+
if (_this.props.hiSelectableListProps && _this.props.hiSelectableListProps.onSelect) {
|
|
402
|
+
_this.props.hiSelectableListProps.onSelect(null, item);
|
|
403
|
+
} else {
|
|
404
|
+
_this.handleSelect(null, item);
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
console.warn("Can not find item #".concat(event.target.id));
|
|
408
|
+
}
|
|
348
409
|
} else if (key === 'enter' && _this.props.multiple) {
|
|
349
410
|
event.preventDefault();
|
|
350
411
|
|
|
@@ -361,6 +422,10 @@ function (_React$PureComponent) {
|
|
|
361
422
|
event.preventDefault();
|
|
362
423
|
|
|
363
424
|
_this.handleClose();
|
|
425
|
+
} else if (key === 'tab') {
|
|
426
|
+
_this.setState({
|
|
427
|
+
open: false
|
|
428
|
+
});
|
|
364
429
|
}
|
|
365
430
|
};
|
|
366
431
|
|
|
@@ -543,7 +608,7 @@ function (_React$PureComponent) {
|
|
|
543
608
|
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
609
|
|
|
545
610
|
var searchInput = function searchInput(position) {
|
|
546
|
-
if (
|
|
611
|
+
if (searchable) {
|
|
547
612
|
return _react.default.createElement(_HiInput.default, (0, _extends2.default)({
|
|
548
613
|
value: searchValue,
|
|
549
614
|
autoFocus: true,
|
|
@@ -567,7 +632,7 @@ function (_React$PureComponent) {
|
|
|
567
632
|
var nbItems = itemList.length <= 10 ? itemList.length + 1 : 11;
|
|
568
633
|
popperStyle.transform = "translate3d(-1px, -".concat(nbItems * 40 + 2, "px, 0px)");
|
|
569
634
|
} else if (this.placement && this.placement.indexOf('top') < 0 && !!searchable) {
|
|
570
|
-
popperStyle.transform =
|
|
635
|
+
popperStyle.transform = 'translate3d(-1px, 40px, 0px)';
|
|
571
636
|
}
|
|
572
637
|
|
|
573
638
|
var content = function content(_ref) {
|
|
@@ -624,6 +689,7 @@ function (_React$PureComponent) {
|
|
|
624
689
|
onClick: this.handleClick,
|
|
625
690
|
onFocus: this.handleFocus,
|
|
626
691
|
onBlur: this.handleBlur,
|
|
692
|
+
onKeyDown: this.handleKeyDownInput,
|
|
627
693
|
onSubmit: onSubmit,
|
|
628
694
|
onMouseEnter: this.props.onMouseEnter,
|
|
629
695
|
onMouseLeave: this.props.onMouseLeave,
|
|
@@ -691,7 +757,8 @@ HiSelect.defaultProps = {
|
|
|
691
757
|
n_children: '%s items',
|
|
692
758
|
one_child: '%s item'
|
|
693
759
|
},
|
|
694
|
-
type: 'text'
|
|
760
|
+
type: 'text',
|
|
761
|
+
filterFunc: filterValue
|
|
695
762
|
};
|
|
696
763
|
HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
697
764
|
align: _propTypes.default.oneOf(['left', 'right']),
|
|
@@ -726,6 +793,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
726
793
|
*/
|
|
727
794
|
fallbackImage: _propTypes.default.string,
|
|
728
795
|
|
|
796
|
+
/*
|
|
797
|
+
* Fonction de filtrage custom
|
|
798
|
+
*/
|
|
799
|
+
filterFunc: _propTypes.default.func,
|
|
800
|
+
|
|
729
801
|
/**
|
|
730
802
|
* Affiche l'élément 'All'
|
|
731
803
|
*/
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = exports.styles = void 0;
|
|
8
|
+
exports.default = exports.filterValue = exports.styles = void 0;
|
|
9
9
|
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
11
|
|
|
@@ -70,6 +70,12 @@ var styles = function styles(theme) {
|
|
|
70
70
|
})
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
+
|
|
74
|
+
exports.styles = styles;
|
|
75
|
+
|
|
76
|
+
var filterValue = function filterValue(item, searchValue) {
|
|
77
|
+
return searchValue === '' || (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(searchValue.toLowerCase())) !== -1;
|
|
78
|
+
};
|
|
73
79
|
/**
|
|
74
80
|
*
|
|
75
81
|
* Utilisé pour tous types de selects dans les formulaires.
|
|
@@ -86,7 +92,7 @@ var styles = function styles(theme) {
|
|
|
86
92
|
*/
|
|
87
93
|
|
|
88
94
|
|
|
89
|
-
exports.
|
|
95
|
+
exports.filterValue = filterValue;
|
|
90
96
|
|
|
91
97
|
var HiSelectContent =
|
|
92
98
|
/*#__PURE__*/
|
|
@@ -253,7 +259,7 @@ function (_React$PureComponent) {
|
|
|
253
259
|
hideCheckbox: true,
|
|
254
260
|
label: 'loading'
|
|
255
261
|
}] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
|
|
256
|
-
return item.label &&
|
|
262
|
+
return item.label && _this.props.filterFunc(item, search);
|
|
257
263
|
})) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
|
|
258
264
|
id: '_all',
|
|
259
265
|
label: _this.props.translations.all
|
|
@@ -395,7 +401,8 @@ HiSelectContent.defaultProps = {
|
|
|
395
401
|
n_children: '%s items',
|
|
396
402
|
one_child: '%s item'
|
|
397
403
|
},
|
|
398
|
-
type: 'text'
|
|
404
|
+
type: 'text',
|
|
405
|
+
filterFunc: filterValue
|
|
399
406
|
};
|
|
400
407
|
HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
401
408
|
autoHeight: _propTypes.default.bool,
|
|
@@ -420,6 +427,11 @@ HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
420
427
|
*/
|
|
421
428
|
fallbackImage: _propTypes.default.string,
|
|
422
429
|
|
|
430
|
+
/*
|
|
431
|
+
* Fonction de filtrage custom
|
|
432
|
+
*/
|
|
433
|
+
filterFunc: _propTypes.default.func,
|
|
434
|
+
|
|
423
435
|
/**
|
|
424
436
|
* Affiche l'élément 'All'
|
|
425
437
|
*/
|
|
@@ -193,8 +193,12 @@ function (_React$PureComponent) {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
_this.handleClick = function (event) {
|
|
196
|
+
// Do not open select if press on resetIcon
|
|
196
197
|
if ((!_this.resetIcon || !_this.resetIcon.contains(event.target)) && _this.props.onClick) {
|
|
197
|
-
|
|
198
|
+
// Do not open select if press enter on button => submit form
|
|
199
|
+
if (event.type !== 'keydown' || (0, _keycode.default)(event) !== 'enter') {
|
|
200
|
+
_this.props.onClick(event);
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
};
|
|
200
204
|
|
|
@@ -209,9 +213,11 @@ function (_React$PureComponent) {
|
|
|
209
213
|
_this.handleBlur = function (event) {
|
|
210
214
|
if ((!_this.input || !_this.input.contains(event.relatedTarget)) && _this.props.onBlur) {
|
|
211
215
|
_this.props.onBlur(event);
|
|
212
|
-
} else if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
|
|
213
|
-
_this.input.focus();
|
|
214
216
|
}
|
|
217
|
+
/* else if (this.input && (!this.resetIcon || !this.resetIcon.contains(event.relatedTarget))) {
|
|
218
|
+
this.input.focus();
|
|
219
|
+
}*/
|
|
220
|
+
|
|
215
221
|
};
|
|
216
222
|
|
|
217
223
|
_this.ref = function (el) {
|
|
@@ -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
|
-
|
|
117
|
-
|
|
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) {
|
|
@@ -122,12 +122,13 @@ var styles = function styles(theme) {
|
|
|
122
122
|
minWidth: '50%',
|
|
123
123
|
padding: '5px 0',
|
|
124
124
|
'&$listItemContentSelected': {
|
|
125
|
-
marginBottom:
|
|
125
|
+
marginBottom: 1,
|
|
126
126
|
marginLeft: -4
|
|
127
127
|
},
|
|
128
128
|
'& strong': {
|
|
129
129
|
fontWeight: theme.typography.fontWeightMedium
|
|
130
|
-
}
|
|
130
|
+
},
|
|
131
|
+
display: 'inline-flex'
|
|
131
132
|
}),
|
|
132
133
|
listItemContentSelected: {},
|
|
133
134
|
label: {
|
|
@@ -173,7 +174,7 @@ var styles = function styles(theme) {
|
|
|
173
174
|
labelContent: {
|
|
174
175
|
display: 'flex',
|
|
175
176
|
alignItems: 'center',
|
|
176
|
-
maxWidth: '
|
|
177
|
+
maxWidth: '85%',
|
|
177
178
|
'&$labelWithoutSecondaryInline': {
|
|
178
179
|
maxWidth: '100%'
|
|
179
180
|
}
|
|
@@ -278,7 +279,8 @@ function (_React$PureComponent) {
|
|
|
278
279
|
}
|
|
279
280
|
|
|
280
281
|
return _react.default.createElement("div", {
|
|
281
|
-
className: classes.label
|
|
282
|
+
className: classes.label,
|
|
283
|
+
title: label
|
|
282
284
|
}, label);
|
|
283
285
|
}
|
|
284
286
|
}, {
|
|
@@ -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
|