@hipay/hipay-material-ui 1.0.0-beta.26 → 1.0.0-beta.28
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/HI-CHANGELOG.md +37 -0
- package/HiCheckbox/HiCheckbox.js +6 -3
- package/HiColoredLabel/HiColoredLabel.js +2 -2
- package/HiDatePicker/HiDateRangeSelector.js +32 -9
- package/HiForm/HiFormControl.js +4 -4
- package/HiForm/HiSearchField.js +7 -1
- package/HiSelect/HiSelect.js +195 -83
- package/HiSelect/HiSuggestSelect.js +22 -6
- package/HiSelect/SelectInput.js +63 -10
- package/HiSelectableList/HiSelectableListItem.js +2 -1
- package/HiTable/BodyCellBuilder.js +22 -16
- package/HiTable/BodyCells/CellAccount.js +1 -5
- package/HiTable/BodyCells/CellAddress.js +3 -50
- package/HiTable/BodyCells/CellCountry.js +0 -4
- package/HiTable/BodyCells/CellDate.js +4 -13
- package/HiTable/BodyCells/CellIcon.js +10 -27
- package/HiTable/BodyCells/CellImage.js +1 -21
- package/HiTable/BodyCells/CellLayout.js +11 -4
- package/HiTable/BodyCells/CellNumeric.js +3 -23
- package/HiTable/BodyCells/CellRate.js +3 -3
- package/HiTable/BodyCells/CellSentinel.js +20 -49
- package/HiTable/BodyCells/CellStatus.js +11 -19
- package/HiTable/BodyCells/CellText.js +3 -10
- package/HiTable/BodyCells/CellThirdPartySecurity.js +4 -18
- package/HiTable/BodyCells/index.js +0 -9
- package/HiTable/BodyRow.js +15 -17
- package/HiTable/HiTable.js +41 -26
- package/HiTable/HiTableBody.js +2 -1
- package/HiTable/HiTableContextMenu.js +4 -3
- package/HiTable/HiTableFooter.js +5 -6
- package/HiTable/constants.js +2 -2
- package/es/HiCheckbox/HiCheckbox.js +6 -3
- package/es/HiColoredLabel/HiColoredLabel.js +2 -2
- package/es/HiDatePicker/HiDateRangeSelector.js +27 -9
- package/es/HiForm/HiFormControl.js +4 -4
- package/es/HiForm/HiSearchField.js +2 -1
- package/es/HiSelect/HiSelect.js +141 -42
- package/es/HiSelect/HiSuggestSelect.js +22 -7
- package/es/HiSelect/SelectInput.js +50 -10
- package/es/HiSelectableList/HiSelectableListItem.js +2 -1
- package/es/HiTable/BodyCellBuilder.js +21 -19
- package/es/HiTable/BodyCells/CellAccount.js +1 -5
- package/es/HiTable/BodyCells/CellAddress.js +3 -44
- package/es/HiTable/BodyCells/CellCountry.js +0 -2
- package/es/HiTable/BodyCells/CellDate.js +4 -10
- package/es/HiTable/BodyCells/CellIcon.js +10 -24
- package/es/HiTable/BodyCells/CellImage.js +1 -21
- package/es/HiTable/BodyCells/CellLayout.js +10 -4
- package/es/HiTable/BodyCells/CellNumeric.js +3 -16
- package/es/HiTable/BodyCells/CellRate.js +3 -3
- package/es/HiTable/BodyCells/CellSentinel.js +20 -46
- package/es/HiTable/BodyCells/CellStatus.js +11 -16
- package/es/HiTable/BodyCells/CellText.js +3 -7
- package/es/HiTable/BodyCells/CellThirdPartySecurity.js +3 -15
- package/es/HiTable/BodyCells/index.js +0 -2
- package/es/HiTable/BodyRow.js +12 -14
- package/es/HiTable/HiTable.js +41 -26
- package/es/HiTable/HiTableBody.js +2 -1
- package/es/HiTable/HiTableContextMenu.js +4 -3
- package/es/HiTable/HiTableFooter.js +6 -6
- package/es/HiTable/constants.js +7 -7
- package/es/utils/HiIconBuilder.js +12 -4
- package/es/utils/hiHelpers.js +1 -1
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +9093 -9629
- package/umd/hipay-material-ui.production.min.js +5 -5
- package/utils/HiIconBuilder.js +13 -3
- package/utils/hiHelpers.js +1 -1
- package/HiTable/BodyCells/CellAccountNumber.js +0 -229
- package/es/HiTable/BodyCells/CellAccountNumber.js +0 -171
package/HiSelect/HiSelect.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.styles = undefined;
|
6
|
+
exports.styles = exports.INFINITESCROLL_ERROR_MESSAGE = undefined;
|
7
7
|
|
8
8
|
var _keys = require('babel-runtime/core-js/object/keys');
|
9
9
|
|
@@ -17,6 +17,10 @@ var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
17
17
|
|
18
18
|
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
19
19
|
|
20
|
+
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
21
|
+
|
22
|
+
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
23
|
+
|
20
24
|
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
21
25
|
|
22
26
|
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
@@ -71,6 +75,10 @@ var _reactPopper = require('react-popper');
|
|
71
75
|
|
72
76
|
var _mdiMaterialUi = require('mdi-material-ui');
|
73
77
|
|
78
|
+
var _reactProptypeConditionalRequire = require('react-proptype-conditional-require');
|
79
|
+
|
80
|
+
var _reactProptypeConditionalRequire2 = _interopRequireDefault(_reactProptypeConditionalRequire);
|
81
|
+
|
74
82
|
var _HiSelectableList = require('../HiSelectableList');
|
75
83
|
|
76
84
|
var _HiSelectableList2 = _interopRequireDefault(_HiSelectableList);
|
@@ -95,7 +103,7 @@ var _HiIconBuilder2 = _interopRequireDefault(_HiIconBuilder);
|
|
95
103
|
|
96
104
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
97
105
|
|
98
|
-
// @inheritedComponent Input
|
106
|
+
var INFINITESCROLL_ERROR_MESSAGE = exports.INFINITESCROLL_ERROR_MESSAGE = 'La propriété "loadMoreResults" est obligatoire si la prop "infiniteScroll" est à true'; // @inheritedComponent Input
|
99
107
|
|
100
108
|
var styles = exports.styles = function styles(theme) {
|
101
109
|
return {
|
@@ -162,7 +170,8 @@ var HiSelect = function (_React$PureComponent) {
|
|
162
170
|
hierarchySelected: {},
|
163
171
|
hierarchy: {},
|
164
172
|
nbOptions: 0,
|
165
|
-
dynamic: props.dynamic || false
|
173
|
+
dynamic: props.dynamic || false,
|
174
|
+
resultsPageNumber: 1
|
166
175
|
};
|
167
176
|
|
168
177
|
// Check if value is in options
|
@@ -221,6 +230,24 @@ var HiSelect = function (_React$PureComponent) {
|
|
221
230
|
}
|
222
231
|
|
223
232
|
(0, _createClass3.default)(HiSelect, [{
|
233
|
+
key: 'componentDidUpdate',
|
234
|
+
value: function componentDidUpdate(prevProps, prevState, prevContext) {
|
235
|
+
var _this2 = this;
|
236
|
+
|
237
|
+
if (this.props.infiniteScroll && !prevState.open && this.state.open && this.optionsContent) {
|
238
|
+
var optionList = this.optionsContent.querySelector('div').querySelector('div');
|
239
|
+
optionList.addEventListener('scroll', function (event) {
|
240
|
+
if (optionList.scrollTop >= event.target.scrollHeight - optionList.offsetHeight && !_this2.props.loadingMoreResults && _this2.props.hasMore) {
|
241
|
+
_this2.props.loadMoreResults(_this2.state.resultsPageNumber + 1);
|
242
|
+
_this2.setState({ resultsPageNumber: _this2.state.resultsPageNumber + 1 });
|
243
|
+
}
|
244
|
+
});
|
245
|
+
} else if (this.optionsContent && this.props.infiniteScroll && !this.state.open && prevState.open) {
|
246
|
+
var _optionList = this.optionsContent.querySelector('div').querySelector('div');
|
247
|
+
_optionList.removeEventListener('scroll');
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}, {
|
224
251
|
key: 'componentWillReceiveProps',
|
225
252
|
value: function componentWillReceiveProps(nextProps) {
|
226
253
|
if (typeof this.props.onSearch !== 'undefined' && this.props.options && this.props.options.length > 0) {
|
@@ -262,6 +289,14 @@ var HiSelect = function (_React$PureComponent) {
|
|
262
289
|
});
|
263
290
|
return { hierarchy: hierarchy, hierarchySelected: hierarchySelected };
|
264
291
|
}
|
292
|
+
}, {
|
293
|
+
key: 'handleReset',
|
294
|
+
value: function handleReset(event) {
|
295
|
+
if (this.props.onReset) {
|
296
|
+
event.stopPropagation();
|
297
|
+
this.props.onReset(event);
|
298
|
+
}
|
299
|
+
}
|
265
300
|
|
266
301
|
// Key down on list items
|
267
302
|
|
@@ -291,7 +326,7 @@ var HiSelect = function (_React$PureComponent) {
|
|
291
326
|
}, {
|
292
327
|
key: 'render',
|
293
328
|
value: function render() {
|
294
|
-
var
|
329
|
+
var _this3 = this;
|
295
330
|
|
296
331
|
var _props = this.props,
|
297
332
|
classes = _props.classes,
|
@@ -315,7 +350,12 @@ var HiSelect = function (_React$PureComponent) {
|
|
315
350
|
placeholder = _props.placeholder,
|
316
351
|
staticPosition = _props.staticPosition,
|
317
352
|
pinnedItem = _props.pinnedItem,
|
318
|
-
hasAll = _props.hasAll
|
353
|
+
hasAll = _props.hasAll,
|
354
|
+
infiniteScroll = _props.infiniteScroll,
|
355
|
+
loadingMoreResults = _props.loadingMoreResults,
|
356
|
+
showNoResults = _props.showNoResults,
|
357
|
+
showMinLength = _props.showMinLength,
|
358
|
+
other = (0, _objectWithoutProperties3.default)(_props, ['classes', 'disabled', 'error', 'loading', 'options', 'checkbox', 'searchable', 'displayAsChip', 'type', 'value', 'translations', 'parentItemSelectable', 'icon', 'parentIcon', 'hoverIcon', 'checkedIcon', 'hierarchic', 'id', 'placeholder', 'staticPosition', 'pinnedItem', 'hasAll', 'infiniteScroll', 'loadingMoreResults', 'showNoResults', 'showMinLength']);
|
319
359
|
var _state = this.state,
|
320
360
|
open = _state.open,
|
321
361
|
suggestions = _state.suggestions,
|
@@ -333,7 +373,7 @@ var HiSelect = function (_React$PureComponent) {
|
|
333
373
|
}
|
334
374
|
|
335
375
|
// If loading
|
336
|
-
if (loading) {
|
376
|
+
if (loading && !loadingMoreResults) {
|
337
377
|
_suggestions.unshift({
|
338
378
|
id: '_loading',
|
339
379
|
type: 'loader',
|
@@ -390,6 +430,28 @@ var HiSelect = function (_React$PureComponent) {
|
|
390
430
|
popperStyle = { width: this.props.containerWidth };
|
391
431
|
}
|
392
432
|
|
433
|
+
if (infiniteScroll && loadingMoreResults) {
|
434
|
+
_suggestions.push({
|
435
|
+
id: '_loading',
|
436
|
+
type: 'loader',
|
437
|
+
disabled: true,
|
438
|
+
centered: true,
|
439
|
+
checkbox: false,
|
440
|
+
label: 'loading'
|
441
|
+
});
|
442
|
+
}
|
443
|
+
|
444
|
+
if (!loading && !loadingMoreResults && _suggestions.length === 0 && (showNoResults || showMinLength)) {
|
445
|
+
suggestions.push({
|
446
|
+
id: '_no_result',
|
447
|
+
type: 'text',
|
448
|
+
disabled: true,
|
449
|
+
centered: true,
|
450
|
+
checkbox: false,
|
451
|
+
label: showNoResults ? translations.no_result_match : translations.min_length
|
452
|
+
});
|
453
|
+
}
|
454
|
+
|
393
455
|
var content = _react2.default.createElement(
|
394
456
|
_ClickAwayListener2.default,
|
395
457
|
{ onClickAway: this.handleClickAway },
|
@@ -407,29 +469,35 @@ var HiSelect = function (_React$PureComponent) {
|
|
407
469
|
autoFocus: true,
|
408
470
|
onSearch: this.props.onSearch,
|
409
471
|
inputRef: function inputRef(el) {
|
410
|
-
|
472
|
+
_this3.searchField = el;
|
411
473
|
},
|
412
474
|
onKeyDown: this.handleKeyDownSearch
|
413
475
|
}),
|
414
|
-
_react2.default.createElement(
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
476
|
+
_react2.default.createElement(
|
477
|
+
'div',
|
478
|
+
{ ref: function ref(content) {
|
479
|
+
return _this3.optionsContent = content;
|
480
|
+
} },
|
481
|
+
_react2.default.createElement(_HiSelectableList2.default, (0, _extends3.default)({
|
482
|
+
type: type,
|
483
|
+
parentItemSelectable: parentItemSelectable,
|
484
|
+
itemList: _suggestions,
|
485
|
+
onSelect: this.handleSelect,
|
486
|
+
selectedIdList: selectedIdList,
|
487
|
+
checkbox: checkbox,
|
488
|
+
hierarchy: this.state.hierarchy,
|
489
|
+
hierarchic: hierarchic,
|
490
|
+
hierarchySelected: this.state.hierarchySelected,
|
491
|
+
translations: translations,
|
492
|
+
icon: icon,
|
493
|
+
parentIcon: parentIcon,
|
494
|
+
hoverIcon: hoverIcon,
|
495
|
+
checkedIcon: checkedIcon,
|
496
|
+
allSelected: allSelected,
|
497
|
+
value: value,
|
498
|
+
onKeyDown: this.handleKeyDown
|
499
|
+
}, other))
|
500
|
+
)
|
433
501
|
)
|
434
502
|
)
|
435
503
|
);
|
@@ -439,7 +507,7 @@ var HiSelect = function (_React$PureComponent) {
|
|
439
507
|
{
|
440
508
|
className: classes.root,
|
441
509
|
ref: function ref(el) {
|
442
|
-
|
510
|
+
_this3.overlay = el;
|
443
511
|
}
|
444
512
|
},
|
445
513
|
_react2.default.createElement(
|
@@ -463,8 +531,10 @@ var HiSelect = function (_React$PureComponent) {
|
|
463
531
|
onMouseEnter: this.props.onMouseEnter,
|
464
532
|
onMouseLeave: this.props.onMouseLeave,
|
465
533
|
refElement: function refElement(el) {
|
466
|
-
|
467
|
-
}
|
534
|
+
_this3.selectInputElement = el;
|
535
|
+
},
|
536
|
+
onSubmit: this.props.onSubmit,
|
537
|
+
onReset: this.props.onReset
|
468
538
|
})
|
469
539
|
),
|
470
540
|
open && (staticPosition ? _react2.default.createElement(
|
@@ -501,12 +571,14 @@ HiSelect.defaultProps = {
|
|
501
571
|
parentItemSelectable: false,
|
502
572
|
displayAsChip: false,
|
503
573
|
dynamic: false,
|
574
|
+
infiniteScroll: false,
|
504
575
|
icon: _react2.default.createElement(_mdiMaterialUi.CheckboxBlankOutline, { style: { width: 20, height: 20 } }),
|
505
576
|
parentIcon: _react2.default.createElement(_mdiMaterialUi.CheckboxBlankOutline, { style: { width: 20, height: 20 } }),
|
506
577
|
hoverIcon: _react2.default.createElement(_mdiMaterialUi.CheckboxBlankOutline, { style: { width: 20, height: 20 } }),
|
507
578
|
checkedIcon: _react2.default.createElement(_mdiMaterialUi.CheckboxMarked, { style: { width: 20, height: 20 } }),
|
508
579
|
translations: {
|
509
580
|
all: 'All',
|
581
|
+
min_length: 'Veuillez saisir 3 caractères minimum',
|
510
582
|
no_result_match: 'No result match',
|
511
583
|
search: 'Search',
|
512
584
|
n_items_selected: '%s items selected',
|
@@ -514,46 +586,42 @@ HiSelect.defaultProps = {
|
|
514
586
|
n_children: '%s items',
|
515
587
|
one_child: '%s item'
|
516
588
|
},
|
517
|
-
staticPosition: false
|
589
|
+
staticPosition: false,
|
590
|
+
loadingMoreResults: false,
|
591
|
+
hasMore: false
|
518
592
|
};
|
519
593
|
|
520
594
|
var _initialiseProps = function _initialiseProps() {
|
521
|
-
var
|
595
|
+
var _this4 = this;
|
522
596
|
|
523
597
|
this.handleClick = function () {
|
524
|
-
if (
|
525
|
-
|
598
|
+
if (_this4.state.open) {
|
599
|
+
_this4.handleClose();
|
526
600
|
} else {
|
527
|
-
if (!
|
528
|
-
//document.body.style.overflow = 'hidden';
|
529
|
-
}
|
530
|
-
|
531
|
-
var options =
|
532
|
-
|
533
|
-
|
534
|
-
if (
|
535
|
-
|
601
|
+
/*if (!this.props.staticPosition) {
|
602
|
+
// document.body.style.overflow = 'hidden';
|
603
|
+
}*/
|
604
|
+
_this4.setState({ open: true });
|
605
|
+
var options = _this4.props.options.slice();
|
606
|
+
_this4.handleSuggestions(options);
|
607
|
+
|
608
|
+
if (_this4.props.onClick) {
|
609
|
+
_this4.props.onClick();
|
536
610
|
}
|
537
611
|
|
538
612
|
// Gestion du focus
|
539
|
-
if (
|
540
|
-
// si searchable, focus sur le champs de recherche
|
541
|
-
var searchField = _this3.searchField;
|
542
|
-
setTimeout(function () {
|
543
|
-
searchField.focus();
|
544
|
-
}, 1);
|
545
|
-
} else if (_this3.overlay) {
|
613
|
+
if (!_this4.props.searchable) {
|
546
614
|
// sinon focus sur le dernier élément selectionné
|
547
|
-
|
615
|
+
_this4.focusOnSelectedItem();
|
548
616
|
}
|
549
617
|
}
|
550
618
|
};
|
551
619
|
|
552
620
|
this.focusOnSelectedItem = function () {
|
553
621
|
// On récupère la div parent "overlay"
|
554
|
-
var overlay = (0, _reactDom.findDOMNode)(
|
555
|
-
var multiple =
|
556
|
-
var value =
|
622
|
+
var overlay = (0, _reactDom.findDOMNode)(_this4.overlay);
|
623
|
+
var multiple = _this4.props.multiple;
|
624
|
+
var value = _this4.props.value;
|
557
625
|
var selectedIdList = Array.isArray(value) ? value : [value];
|
558
626
|
setTimeout(function () {
|
559
627
|
var focused = false;
|
@@ -588,10 +656,12 @@ var _initialiseProps = function _initialiseProps() {
|
|
588
656
|
} else if (event.key === 'ArrowUp') {
|
589
657
|
nextItem = (0, _hiHelpers.getNextItemSelectable)(document.activeElement, 'up');
|
590
658
|
} else if (event.key === 'Tab') {
|
591
|
-
if (!
|
592
|
-
|
593
|
-
}
|
594
|
-
|
659
|
+
/* if (!this.props.staticPosition) {
|
660
|
+
document.body.style.overflow = 'auto';
|
661
|
+
} */
|
662
|
+
_this4.setState({ open: false });
|
663
|
+
} else if (event.key === 'Escape') {
|
664
|
+
_this4.setState({ open: false });
|
595
665
|
}
|
596
666
|
if (nextItem) {
|
597
667
|
nextItem.focus();
|
@@ -599,51 +669,53 @@ var _initialiseProps = function _initialiseProps() {
|
|
599
669
|
};
|
600
670
|
|
601
671
|
this.handleKeyDownSearch = function (event) {
|
602
|
-
if (
|
603
|
-
|
672
|
+
if (_this4.overlay && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
673
|
+
_this4.focusOnSelectedItem();
|
674
|
+
} else if (event.key === 'Enter' && _this4.props.onSubmit) {
|
675
|
+
_this4.props.onSubmit(event);
|
604
676
|
}
|
605
677
|
};
|
606
678
|
|
607
679
|
this.handleFocus = function () {
|
608
|
-
|
680
|
+
_this4.setState({ focused: true });
|
609
681
|
};
|
610
682
|
|
611
683
|
this.handleBlur = function () {
|
612
|
-
|
684
|
+
_this4.setState({ focused: false });
|
613
685
|
};
|
614
686
|
|
615
687
|
this.handleClose = function () {
|
616
|
-
if (!
|
688
|
+
if (!_this4.props.staticPosition) {
|
617
689
|
//document.body.style.overflow = 'auto';
|
618
690
|
}
|
619
|
-
|
691
|
+
_this4.setState({
|
620
692
|
open: false
|
621
693
|
});
|
622
694
|
|
623
|
-
if (
|
624
|
-
|
695
|
+
if (_this4.props.onClose) {
|
696
|
+
_this4.props.onClose();
|
625
697
|
}
|
626
|
-
if (
|
627
|
-
|
698
|
+
if (_this4.selectInputElement) {
|
699
|
+
_this4.selectInputElement.focus();
|
628
700
|
}
|
629
701
|
};
|
630
702
|
|
631
703
|
this.handleClickAway = function (event) {
|
632
704
|
// Au clic sur le bouton, on laisse le handleClick fermer le select
|
633
|
-
if (!
|
634
|
-
|
705
|
+
if (!_this4.selectInputElement.contains(event.target)) {
|
706
|
+
_this4.handleClose(event);
|
635
707
|
}
|
636
708
|
};
|
637
709
|
|
638
710
|
this.handleSelect = function (event, item) {
|
639
|
-
var _props2 =
|
711
|
+
var _props2 = _this4.props,
|
640
712
|
multiple = _props2.multiple,
|
641
713
|
value = _props2.value,
|
642
714
|
onChange = _props2.onChange,
|
643
715
|
options = _props2.options,
|
644
716
|
hierarchic = _props2.hierarchic,
|
645
717
|
pinnedItem = _props2.pinnedItem;
|
646
|
-
var _state2 =
|
718
|
+
var _state2 = _this4.state,
|
647
719
|
hierarchySelected = _state2.hierarchySelected,
|
648
720
|
hierarchy = _state2.hierarchy,
|
649
721
|
nbOptions = _state2.nbOptions;
|
@@ -682,7 +754,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
682
754
|
if (item.hasChildren === true) {
|
683
755
|
// remove all children
|
684
756
|
valueList = valueList.filter(function (val) {
|
685
|
-
return !
|
757
|
+
return !_this4.state.hierarchy[item.id].includes(val);
|
686
758
|
});
|
687
759
|
hiSelected[item.id] = [];
|
688
760
|
} else if (item.hasOwnProperty('parentId')) {
|
@@ -710,8 +782,8 @@ var _initialiseProps = function _initialiseProps() {
|
|
710
782
|
// Si item parent => on ajoute tous les enfants
|
711
783
|
// Ou on les supprime s'ils sont déjà tous sélectionnés (dans une liste filtrée)
|
712
784
|
var idsInSuggestions = [];
|
713
|
-
|
714
|
-
if (
|
785
|
+
_this4.state.suggestions.forEach(function (suggestion) {
|
786
|
+
if (_this4.state.hierarchy[item.id].includes(suggestion.id)) {
|
715
787
|
idsInSuggestions.push(suggestion.id);
|
716
788
|
}
|
717
789
|
});
|
@@ -735,31 +807,33 @@ var _initialiseProps = function _initialiseProps() {
|
|
735
807
|
hiSelected[item.id] = (0, _hiHelpers.arrayUnique)(hiSelected[item.id].concat(idsInSuggestions));
|
736
808
|
}
|
737
809
|
|
738
|
-
|
810
|
+
_this4.setState({ hierarchySelected: hiSelected });
|
739
811
|
} else if (item.hasOwnProperty('parentId')) {
|
740
812
|
// Si item est un enfant on l'ajoute du tableau associatif des
|
741
813
|
// elmts sélectionnés
|
742
814
|
hiSelected[item.parentId].push(item.id);
|
743
815
|
}
|
744
816
|
}
|
745
|
-
|
817
|
+
_this4.setState({ hierarchySelected: hiSelected });
|
746
818
|
onChange(event, valueList, item);
|
747
819
|
} else {
|
748
820
|
onChange(event, item.id, item);
|
749
|
-
|
821
|
+
_this4.handleClose();
|
750
822
|
}
|
751
823
|
};
|
752
824
|
|
753
825
|
this.handleSuggestions = function (suggestions) {
|
754
|
-
var _props3 =
|
826
|
+
var _props3 = _this4.props,
|
755
827
|
options = _props3.options,
|
756
828
|
hasAll = _props3.hasAll,
|
757
829
|
iconAll = _props3.iconAll,
|
758
830
|
translations = _props3.translations,
|
759
|
-
multiple = _props3.multiple
|
831
|
+
multiple = _props3.multiple,
|
832
|
+
showNoResults = _props3.showNoResults,
|
833
|
+
showMinLength = _props3.showMinLength;
|
760
834
|
|
761
835
|
|
762
|
-
if (suggestions.length === 0) {
|
836
|
+
if (suggestions.length === 0 && (showNoResults || showMinLength)) {
|
763
837
|
// Handle No Result
|
764
838
|
// FIX to remove all item
|
765
839
|
suggestions = [];
|
@@ -769,7 +843,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
769
843
|
disabled: true,
|
770
844
|
centered: true,
|
771
845
|
checkbox: false,
|
772
|
-
label: translations.no_result_match
|
846
|
+
label: showNoResults ? translations.no_result_match : translations.min_length
|
773
847
|
});
|
774
848
|
} else if (hasAll && suggestions.length > 0 && suggestions.length === options.length && multiple === true) {
|
775
849
|
// Handle 'All'
|
@@ -788,14 +862,14 @@ var _initialiseProps = function _initialiseProps() {
|
|
788
862
|
}
|
789
863
|
}
|
790
864
|
|
791
|
-
|
865
|
+
_this4.setState({
|
792
866
|
suggestions: suggestions
|
793
867
|
});
|
794
868
|
};
|
795
869
|
|
796
870
|
this.handleRequestDelete = function (evt) {
|
797
871
|
evt.stopPropagation();
|
798
|
-
|
872
|
+
_this4.props.onChange(_this4.props.name, []);
|
799
873
|
};
|
800
874
|
};
|
801
875
|
|
@@ -838,6 +912,10 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
838
912
|
* Les items sont hiérarchisés
|
839
913
|
*/
|
840
914
|
hierarchic: _propTypes2.default.bool,
|
915
|
+
/**
|
916
|
+
* Indique si l'infinite scroll doit rechercher de nouveaux résultats
|
917
|
+
*/
|
918
|
+
hasMore: _propTypes2.default.bool,
|
841
919
|
/**
|
842
920
|
* Icon affiché lorsque l'item n'est pas sélectionné et qu'on le survole
|
843
921
|
*/
|
@@ -854,10 +932,28 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
854
932
|
* id du select
|
855
933
|
*/
|
856
934
|
id: _propTypes2.default.string,
|
935
|
+
/**
|
936
|
+
* Infinite scroll dans le select dans le cas où il y a beaucoup de résultats à afficher
|
937
|
+
* afin d'éviter un lag du navigateur
|
938
|
+
*/
|
939
|
+
infiniteScroll: _propTypes2.default.bool.isRequired,
|
857
940
|
/**
|
858
941
|
* Ajoute un loader
|
859
942
|
*/
|
860
943
|
loading: _propTypes2.default.bool,
|
944
|
+
/**
|
945
|
+
* Ajoute un loader en bas pour l'infiniteScroll
|
946
|
+
*/
|
947
|
+
loadingMoreResults: _propTypes2.default.bool,
|
948
|
+
/**
|
949
|
+
* Fonction de callback appelée lorsque l'utilisateur arrive en bas de la liste des options
|
950
|
+
* afin de charger les nouvelles options
|
951
|
+
*
|
952
|
+
* @param {int} pageNumber
|
953
|
+
*/
|
954
|
+
loadMoreResults: (0, _reactProptypeConditionalRequire2.default)(_propTypes2.default.func, function (props) {
|
955
|
+
return props.hasOwnProperty('infiniteScroll') && props.infiniteScroll === true;
|
956
|
+
}, INFINITESCROLL_ERROR_MESSAGE),
|
861
957
|
/**
|
862
958
|
* Autorise la sélection de plusieurs valeurs
|
863
959
|
*/
|
@@ -885,6 +981,10 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
885
981
|
* Fonction de callback appelée lorsque le curseur quitte le champs
|
886
982
|
*/
|
887
983
|
onMouseLeave: _propTypes2.default.func,
|
984
|
+
/**
|
985
|
+
* Fonction de callback appelée lorsqu'on vide le champs
|
986
|
+
*/
|
987
|
+
onReset: _propTypes2.default.func,
|
888
988
|
/**
|
889
989
|
* Fonction de callback appelée lorsqu'on écrit dans la barre de recherche
|
890
990
|
* A utiliser pour les selects avec des données dynamiques
|
@@ -893,6 +993,10 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
893
993
|
* @param {string} value
|
894
994
|
*/
|
895
995
|
onSearch: _propTypes2.default.func,
|
996
|
+
/**
|
997
|
+
* Fonction de callback à la pression de la touche "Entrée"
|
998
|
+
*/
|
999
|
+
onSubmit: _propTypes2.default.func,
|
896
1000
|
/**
|
897
1001
|
* Listes des options du select
|
898
1002
|
*/
|
@@ -922,6 +1026,14 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
922
1026
|
* Si true, le contenu du select sera dans une div static plutot que dans une popper absolute
|
923
1027
|
*/
|
924
1028
|
staticPosition: _propTypes2.default.bool,
|
1029
|
+
/**
|
1030
|
+
* Permet d'afficher un message si pas assez de caractères
|
1031
|
+
*/
|
1032
|
+
showMinLength: _propTypes2.default.bool,
|
1033
|
+
/**
|
1034
|
+
* Permet d'afficher un message si aucune options n'est présente
|
1035
|
+
*/
|
1036
|
+
showNoResults: _propTypes2.default.bool,
|
925
1037
|
/**
|
926
1038
|
* Traductions (par défaut en anglais)
|
927
1039
|
*/
|
@@ -187,11 +187,12 @@ var HiSuggestSelect = function (_React$PureComponent) {
|
|
187
187
|
var _props = this.props,
|
188
188
|
classes = _props.classes,
|
189
189
|
id = _props.id,
|
190
|
+
loading = _props.loading,
|
190
191
|
showMinLength = _props.showMinLength,
|
191
192
|
showNoResults = _props.showNoResults,
|
192
193
|
onSearch = _props.onSearch,
|
193
194
|
translations = _props.translations,
|
194
|
-
otherProps = (0, _objectWithoutProperties3.default)(_props, ['classes', 'id', 'showMinLength', 'showNoResults', 'onSearch', 'translations']);
|
195
|
+
otherProps = (0, _objectWithoutProperties3.default)(_props, ['classes', 'id', 'loading', 'showMinLength', 'showNoResults', 'onSearch', 'translations']);
|
195
196
|
var _state = this.state,
|
196
197
|
focused = _state.focused,
|
197
198
|
options = _state.options;
|
@@ -199,17 +200,28 @@ var HiSuggestSelect = function (_React$PureComponent) {
|
|
199
200
|
|
200
201
|
var optionsShown = options;
|
201
202
|
|
202
|
-
// If
|
203
|
-
if (
|
203
|
+
// If loading
|
204
|
+
if (loading) {
|
204
205
|
optionsShown = [{
|
205
|
-
id: '
|
206
|
-
type: '
|
206
|
+
id: '_loading',
|
207
|
+
type: 'loader',
|
207
208
|
disabled: true,
|
208
209
|
centered: true,
|
209
210
|
checkbox: false,
|
210
|
-
label:
|
211
|
+
label: 'loading'
|
211
212
|
}];
|
212
213
|
}
|
214
|
+
// If no results match
|
215
|
+
else if (options.length === 0 && (showNoResults || showMinLength)) {
|
216
|
+
optionsShown = [{
|
217
|
+
id: '_no_result',
|
218
|
+
type: 'text',
|
219
|
+
disabled: true,
|
220
|
+
centered: true,
|
221
|
+
checkbox: false,
|
222
|
+
label: showNoResults ? translations.no_result_match : translations.min_length
|
223
|
+
}];
|
224
|
+
}
|
213
225
|
|
214
226
|
var open = !!optionsShown.length && focused;
|
215
227
|
|
@@ -289,6 +301,10 @@ HiSuggestSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
289
301
|
* id de l'élément input
|
290
302
|
*/
|
291
303
|
id: _propTypes2.default.string,
|
304
|
+
/**
|
305
|
+
* Ajoute un loader
|
306
|
+
*/
|
307
|
+
loading: _propTypes2.default.bool,
|
292
308
|
/**
|
293
309
|
* Fonction de callback appelée lorsqu'on écrit dans le champ
|
294
310
|
*/
|