@hipay/hipay-material-ui 2.0.0-beta.75 → 2.0.0-beta.76
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +77 -0
- package/HiAlertModal/HiAlertModal.js +1 -1
- package/HiChip/HiChip.js +17 -1
- package/HiDatePicker/HiDatePicker.js +130 -125
- package/HiDatePicker/HiDatePickerMobile.js +127 -0
- package/HiDatePicker/HiDateRangePicker.js +53 -11
- package/HiDatePicker/HiDateRangeSelector.js +3 -1
- package/HiDatePicker/stylesheet.js +16 -0
- package/HiSelect/HiSelect.js +115 -37
- package/HiSelect/HiSelectInput.js +6 -1
- package/HiSelect/HiSelectMobile.js +198 -0
- package/es/HiAlertModal/HiAlertModal.js +1 -1
- package/es/HiChip/HiChip.js +17 -1
- package/es/HiDatePicker/HiDatePicker.js +149 -133
- package/es/HiDatePicker/HiDatePickerMobile.js +89 -0
- package/es/HiDatePicker/HiDateRangePicker.js +47 -9
- package/es/HiDatePicker/HiDateRangeSelector.js +2 -1
- package/es/HiDatePicker/stylesheet.js +16 -0
- package/es/HiSelect/HiSelect.js +110 -39
- package/es/HiSelect/HiSelectInput.js +6 -1
- package/es/HiSelect/HiSelectMobile.js +149 -0
- package/es/styles/createPalette.js +1 -1
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +3 -2
- package/styles/createPalette.js +1 -1
@@ -59,6 +59,10 @@ var _stylesheet = _interopRequireDefault(require("./stylesheet"));
|
|
59
59
|
|
60
60
|
var _HiFormControl = _interopRequireDefault(require("../HiForm/HiFormControl"));
|
61
61
|
|
62
|
+
var _reactDeviceDetect = require("react-device-detect");
|
63
|
+
|
64
|
+
var _HiDatePickerMobile = _interopRequireDefault(require("./HiDatePickerMobile"));
|
65
|
+
|
62
66
|
var HiDateRangePicker =
|
63
67
|
/*#__PURE__*/
|
64
68
|
function (_React$Component) {
|
@@ -188,6 +192,18 @@ function (_React$Component) {
|
|
188
192
|
_this.props.onChange("".concat(name, "Error"), error);
|
189
193
|
};
|
190
194
|
|
195
|
+
_this.handleChangeMobile = function (inputName) {
|
196
|
+
return function (event) {
|
197
|
+
var date;
|
198
|
+
|
199
|
+
if (event.target.value) {
|
200
|
+
date = new Date(event.target.value);
|
201
|
+
}
|
202
|
+
|
203
|
+
_this.props.onChange(inputName, date);
|
204
|
+
};
|
205
|
+
};
|
206
|
+
|
191
207
|
_this.handleCurrentMonthChange = function (day) {
|
192
208
|
_this.setState({
|
193
209
|
currentMonth: day,
|
@@ -511,17 +527,17 @@ function (_React$Component) {
|
|
511
527
|
onSubmit: this.props.onSubmit
|
512
528
|
}
|
513
529
|
});
|
514
|
-
var toClass = (0, _classnames.default)(classes.toInput, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.absolute, staticPosition === true && this.state.focusedInput === 'from'), (0, _defineProperty2.default)(_classNames, classes.right4, staticPosition === true && this.state.focusedInput === 'from'), _classNames));
|
530
|
+
var toClass = (0, _classnames.default)(classes.toInput, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.absolute, !_reactDeviceDetect.isMobile && staticPosition === true && this.state.focusedInput === 'from'), (0, _defineProperty2.default)(_classNames, classes.right4, !_reactDeviceDetect.isMobile && staticPosition === true && this.state.focusedInput === 'from'), _classNames));
|
515
531
|
|
516
532
|
var content = _react.default.createElement("div", {
|
517
533
|
className: (0, _classnames.default)(classes.root, classes.rangePickerContainer)
|
518
534
|
}, _react.default.createElement("div", {
|
519
535
|
className: classes.fromInput,
|
520
|
-
onFocus: function
|
536
|
+
onFocus: !_reactDeviceDetect.isMobile ? function () {
|
521
537
|
return _this2.handleDayPickerFocus('from');
|
522
|
-
},
|
523
|
-
onKeyDown: this.handleKeyDown('from')
|
524
|
-
}, _react.default.createElement("div", null, _react.default.createElement(_DayPickerInput.default, {
|
538
|
+
} : undefined,
|
539
|
+
onKeyDown: !_reactDeviceDetect.isMobile ? this.handleKeyDown('from') : undefined
|
540
|
+
}, _react.default.createElement("div", null, !_reactDeviceDetect.isMobile ? _react.default.createElement(_DayPickerInput.default, {
|
525
541
|
key: '1',
|
526
542
|
ref: function ref(el) {
|
527
543
|
_this2.fromInput = el;
|
@@ -539,16 +555,29 @@ function (_React$Component) {
|
|
539
555
|
return _this2.handleDayChange('from', day);
|
540
556
|
},
|
541
557
|
placeholder: ''
|
558
|
+
}) : _react.default.createElement(_HiDatePickerMobile.default, {
|
559
|
+
id: this.props.id,
|
560
|
+
label: labelFrom,
|
561
|
+
range: true,
|
562
|
+
required: this.props.required,
|
563
|
+
enableTime: enableTime,
|
564
|
+
value: from,
|
565
|
+
onChange: this.handleChangeMobile('from'),
|
566
|
+
disablePastDays: this.props.disablePastDays,
|
567
|
+
disableFutureDays: disableFutureDays,
|
568
|
+
today: today,
|
569
|
+
minimumDate: minimumDate,
|
570
|
+
format: enableTime ? "".concat(format, " HH:mm") : format
|
542
571
|
}))), _react.default.createElement("div", {
|
543
572
|
className: toClass,
|
544
|
-
onFocus: function
|
573
|
+
onFocus: !_reactDeviceDetect.isMobile ? function () {
|
545
574
|
return _this2.handleDayPickerFocus('to');
|
546
|
-
},
|
547
|
-
onBlur: function
|
575
|
+
} : undefined,
|
576
|
+
onBlur: !_reactDeviceDetect.isMobile ? function () {
|
548
577
|
return _this2.handleDayPickerBlur('to');
|
549
|
-
},
|
550
|
-
onKeyDown: this.handleKeyDown('to')
|
551
|
-
}, _react.default.createElement(_DayPickerInput.default, {
|
578
|
+
} : undefined,
|
579
|
+
onKeyDown: !_reactDeviceDetect.isMobile ? this.handleKeyDown('to') : undefined
|
580
|
+
}, !_reactDeviceDetect.isMobile ? _react.default.createElement(_DayPickerInput.default, {
|
552
581
|
key: '1',
|
553
582
|
ref: function ref(el) {
|
554
583
|
_this2.toInput = el;
|
@@ -563,6 +592,19 @@ function (_React$Component) {
|
|
563
592
|
formatDate: _moment.default.formatDate,
|
564
593
|
parseDate: _moment.default.parseDate,
|
565
594
|
placeholder: ''
|
595
|
+
}) : _react.default.createElement(_HiDatePickerMobile.default, {
|
596
|
+
id: this.props.id,
|
597
|
+
label: labelTo,
|
598
|
+
range: true,
|
599
|
+
required: this.props.required,
|
600
|
+
enableTime: enableTime,
|
601
|
+
value: to,
|
602
|
+
onChange: this.handleChangeMobile('to'),
|
603
|
+
disablePastDays: this.props.disablePastDays,
|
604
|
+
disableFutureDays: disableFutureDays,
|
605
|
+
today: today,
|
606
|
+
minimumDate: minimumDate,
|
607
|
+
format: enableTime ? "".concat(format, " HH:mm") : format
|
566
608
|
})));
|
567
609
|
|
568
610
|
if (!hasSelector) {
|
@@ -45,6 +45,8 @@ var _HiDateRangePicker = _interopRequireDefault(require("./HiDateRangePicker"));
|
|
45
45
|
|
46
46
|
var _HiFormControl = _interopRequireDefault(require("../HiForm/HiFormControl"));
|
47
47
|
|
48
|
+
var _reactDeviceDetect = require("react-device-detect");
|
49
|
+
|
48
50
|
function findSeparator(format) {
|
49
51
|
var str = '';
|
50
52
|
|
@@ -370,7 +372,7 @@ function (_React$Component) {
|
|
370
372
|
},
|
371
373
|
staticPosition: staticPosition,
|
372
374
|
onSubmit: this.props.onSubmit
|
373
|
-
}, selectProps))), _react.default.createElement(_Grid.default, {
|
375
|
+
}, selectProps))), (_reactDeviceDetect.isMobile && selectedPreset === 'custom' || !_reactDeviceDetect.isMobile) && _react.default.createElement(_Grid.default, {
|
374
376
|
item: true,
|
375
377
|
xs: 12,
|
376
378
|
sm: 8,
|
@@ -20,6 +20,22 @@ var _default = function _default(theme) {
|
|
20
20
|
minWidth: 252,
|
21
21
|
maxWidth: 500
|
22
22
|
},
|
23
|
+
rootMobile: (0, _extends2.default)({}, theme.typography.b1, {
|
24
|
+
backgroundColor: theme.palette.background2,
|
25
|
+
borderBottom: '1px solid #E0E0E0',
|
26
|
+
borderLeft: 'none',
|
27
|
+
borderRight: 'none',
|
28
|
+
borderTop: 'none',
|
29
|
+
height: 40,
|
30
|
+
paddingLeft: 8,
|
31
|
+
paddingTop: 10,
|
32
|
+
position: 'absolute',
|
33
|
+
marginTop: -40,
|
34
|
+
opacity: 0
|
35
|
+
}),
|
36
|
+
mobileRangeRoot: {
|
37
|
+
minWidth: '100%'
|
38
|
+
},
|
23
39
|
fromInput: {
|
24
40
|
position: 'relative',
|
25
41
|
display: 'inline-block',
|
package/HiSelect/HiSelect.js
CHANGED
@@ -55,6 +55,14 @@ var _keycode = _interopRequireDefault(require("keycode"));
|
|
55
55
|
|
56
56
|
var _classnames = _interopRequireDefault(require("classnames"));
|
57
57
|
|
58
|
+
var _HiAlertModal = _interopRequireDefault(require("../HiAlertModal"));
|
59
|
+
|
60
|
+
var _reactDeviceDetect = require("react-device-detect");
|
61
|
+
|
62
|
+
var _HiSelectMobile = _interopRequireDefault(require("./HiSelectMobile"));
|
63
|
+
|
64
|
+
var _reactDom = require("react-dom");
|
65
|
+
|
58
66
|
var styles = function styles(theme) {
|
59
67
|
return {
|
60
68
|
root: {
|
@@ -260,30 +268,48 @@ function (_React$PureComponent) {
|
|
260
268
|
_this.handleClick = function () {
|
261
269
|
if (_this.state.open) {
|
262
270
|
_this.handleClose();
|
271
|
+
} else if (_this.props.alert && !_this.state.alertOpen) {
|
272
|
+
_this.setState({
|
273
|
+
open: false,
|
274
|
+
alertOpen: true
|
275
|
+
});
|
263
276
|
} else {
|
264
277
|
_this.setState({
|
265
|
-
open: true
|
278
|
+
open: true,
|
279
|
+
alertOpen: false
|
266
280
|
});
|
267
281
|
|
268
282
|
_this.handleSuggestions(_this.props.options);
|
269
283
|
|
270
284
|
if (_this.props.onClick) _this.props.onClick(); // Gestion du focus
|
271
285
|
|
272
|
-
|
273
|
-
|
286
|
+
setTimeout(function () {
|
287
|
+
if (!_this.props.searchable) {
|
274
288
|
// Sinon focus sur l'élément sélectionné
|
275
289
|
_this.focusOnSelectedItem(_this.props.value);
|
276
|
-
}, 1);
|
277
|
-
} else {
|
278
|
-
if (_this.searchField) {
|
279
|
-
setTimeout(function () {
|
280
|
-
_this.searchField.focus();
|
281
|
-
}, 1);
|
282
290
|
}
|
283
|
-
}
|
291
|
+
}, 1);
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
_this.handleSubmitAlert = function () {
|
296
|
+
_this.handleClick();
|
297
|
+
};
|
298
|
+
|
299
|
+
_this.handleCancelAlert = function () {
|
300
|
+
_this.handleClose();
|
301
|
+
};
|
302
|
+
|
303
|
+
_this.handleExitedAlert = function () {
|
304
|
+
if (_this.searchField) {
|
305
|
+
_this.searchField.focus();
|
284
306
|
}
|
285
307
|
};
|
286
308
|
|
309
|
+
_this.handleCloseAlert = function () {
|
310
|
+
_this.handleClose();
|
311
|
+
};
|
312
|
+
|
287
313
|
_this.focusOnSelectedItem = function (selectedValue) {
|
288
314
|
if (_this.overlay && _this.overlay.getElementsByTagName('li')[0]) {
|
289
315
|
setTimeout(function () {
|
@@ -316,7 +342,8 @@ function (_React$PureComponent) {
|
|
316
342
|
_this.handleSearchReset();
|
317
343
|
|
318
344
|
_this.setState({
|
319
|
-
open: false
|
345
|
+
open: false,
|
346
|
+
alertOpen: false
|
320
347
|
});
|
321
348
|
|
322
349
|
if (_this.props.onClose) {
|
@@ -351,32 +378,24 @@ function (_React$PureComponent) {
|
|
351
378
|
_this.handleKeyDown = function (event) {
|
352
379
|
var key = (0, _keycode.default)(event);
|
353
380
|
|
354
|
-
if (
|
355
|
-
|
381
|
+
if (!_this.state.alertOpen) {
|
382
|
+
if (key === 'esc') {
|
383
|
+
event.preventDefault();
|
356
384
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
385
|
+
_this.handleClose();
|
386
|
+
} else if (key === 'enter') {
|
387
|
+
if (_this.state.open) {
|
388
|
+
if (_this.props.multiple) {
|
389
|
+
_this.handleClose();
|
390
|
+
}
|
362
391
|
}
|
363
|
-
}
|
364
|
-
|
365
|
-
event.preventDefault();
|
392
|
+
} else if (key === 'space' && event.target !== _this.searchField) {
|
393
|
+
event.preventDefault();
|
366
394
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
open: false
|
371
|
-
});
|
372
|
-
}
|
373
|
-
} else {
|
374
|
-
_this.setState({
|
375
|
-
open: true
|
376
|
-
});
|
395
|
+
_this.handleClick();
|
396
|
+
} else if (key === 'tab') {
|
397
|
+
_this.handleClose();
|
377
398
|
}
|
378
|
-
} else if (key === 'tab') {
|
379
|
-
_this.handleClose();
|
380
399
|
}
|
381
400
|
};
|
382
401
|
|
@@ -425,6 +444,11 @@ function (_React$PureComponent) {
|
|
425
444
|
return option.id;
|
426
445
|
}), item);
|
427
446
|
}
|
447
|
+
} else if (_reactDeviceDetect.isMobile && multiple) {
|
448
|
+
// Array of selected values
|
449
|
+
onChange(event, item.map(function (option) {
|
450
|
+
return option.id;
|
451
|
+
}), item);
|
428
452
|
} else if (value.includes(item.id)) {
|
429
453
|
// unselect item
|
430
454
|
onChange(event, value.filter(function (id) {
|
@@ -489,11 +513,13 @@ function (_React$PureComponent) {
|
|
489
513
|
};
|
490
514
|
|
491
515
|
_this.state = {
|
516
|
+
alertOpen: false,
|
492
517
|
open: false,
|
493
518
|
focused: false,
|
494
519
|
searchValue: props.searchValue ? undefined : '',
|
495
520
|
suggestions: props.options,
|
496
|
-
openDown: true
|
521
|
+
openDown: true,
|
522
|
+
overlayWidth: 0
|
497
523
|
};
|
498
524
|
_this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)(_this));
|
499
525
|
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)(_this));
|
@@ -514,6 +540,12 @@ function (_React$PureComponent) {
|
|
514
540
|
if (this.props.autoFocus) {
|
515
541
|
this.inputEl.focus();
|
516
542
|
}
|
543
|
+
|
544
|
+
if (this.overlay) {
|
545
|
+
this.setState({
|
546
|
+
overlayWidth: (0, _reactDom.findDOMNode)(this.overlay).clientWidth
|
547
|
+
});
|
548
|
+
}
|
517
549
|
}
|
518
550
|
}, {
|
519
551
|
key: "getLengthItemList",
|
@@ -539,6 +571,7 @@ function (_React$PureComponent) {
|
|
539
571
|
_this3 = this;
|
540
572
|
|
541
573
|
var _this$props4 = this.props,
|
574
|
+
alert = _this$props4.alert,
|
542
575
|
classes = _this$props4.classes,
|
543
576
|
disabled = _this$props4.disabled,
|
544
577
|
error = _this$props4.error,
|
@@ -564,6 +597,7 @@ function (_React$PureComponent) {
|
|
564
597
|
_this$props4$buildSel = _this$props4.buildSelectProps,
|
565
598
|
buildSelectProps = _this$props4$buildSel === void 0 ? this.buildSelectProps : _this$props4$buildSel;
|
566
599
|
var _this$state = this.state,
|
600
|
+
alertOpen = _this$state.alertOpen,
|
567
601
|
open = _this$state.open,
|
568
602
|
focused = _this$state.focused;
|
569
603
|
|
@@ -664,14 +698,24 @@ function (_React$PureComponent) {
|
|
664
698
|
}, hiSelectableListProps))), _this3.placement && _this3.placement.indexOf('top') >= 0 && !staticPosition && searchInput('top'))));
|
665
699
|
};
|
666
700
|
|
667
|
-
return _react.default.createElement("div", {
|
701
|
+
return !_reactDeviceDetect.isMobile ? _react.default.createElement("div", {
|
668
702
|
className: classes.root,
|
669
703
|
ref: function ref(el) {
|
670
704
|
_this3.overlay = el;
|
671
705
|
},
|
672
706
|
onKeyDown: this.handleKeyDown,
|
673
707
|
onKeyDownCapture: this.handleKeyDownCapture
|
674
|
-
}, _react.default.createElement(
|
708
|
+
}, alert && _react.default.createElement(_HiAlertModal.default, {
|
709
|
+
open: alertOpen,
|
710
|
+
title: alert.title,
|
711
|
+
content: alert.content,
|
712
|
+
onSubmitClick: this.handleSubmitAlert,
|
713
|
+
onCancelClick: this.handleCancelAlert,
|
714
|
+
onClose: this.handleCloseAlert,
|
715
|
+
onExited: this.handleExitedAlert,
|
716
|
+
labelSubmitButton: alert.submitButton,
|
717
|
+
labelCancelButton: alert.cancelButton
|
718
|
+
}), _react.default.createElement(_HiSelectInput.default, (0, _extends2.default)({
|
675
719
|
id: id,
|
676
720
|
value: inputValue,
|
677
721
|
open: open,
|
@@ -702,7 +746,37 @@ function (_React$PureComponent) {
|
|
702
746
|
className: popperClass,
|
703
747
|
disablePortal: true,
|
704
748
|
style: popperStyle
|
705
|
-
}, content))
|
749
|
+
}, content)) : _react.default.createElement("div", {
|
750
|
+
ref: function ref(el) {
|
751
|
+
_this3.overlay = el;
|
752
|
+
}
|
753
|
+
}, _react.default.createElement(_HiSelectInput.default, (0, _extends2.default)({
|
754
|
+
id: id,
|
755
|
+
value: inputValue,
|
756
|
+
open: open,
|
757
|
+
focused: focused,
|
758
|
+
type: type,
|
759
|
+
disabled: disabled,
|
760
|
+
noButton: displayAsChip,
|
761
|
+
error: error,
|
762
|
+
onFocus: this.handleFocus,
|
763
|
+
onBlur: this.handleBlur,
|
764
|
+
onMouseEnter: this.props.onMouseEnter,
|
765
|
+
onMouseLeave: this.props.onMouseLeave,
|
766
|
+
onReset: this.props.onReset,
|
767
|
+
placeholder: placeholder
|
768
|
+
}, hiSelectInputProps, {
|
769
|
+
refElement: function refElement(el) {
|
770
|
+
_this3.inputEl = el;
|
771
|
+
}
|
772
|
+
})), _react.default.createElement(_HiSelectMobile.default, {
|
773
|
+
onChange: this.handleSelect,
|
774
|
+
multiple: multiple,
|
775
|
+
id: id,
|
776
|
+
itemList: itemList,
|
777
|
+
value: value,
|
778
|
+
width: this.state.overlayWidth
|
779
|
+
}));
|
706
780
|
}
|
707
781
|
}], [{
|
708
782
|
key: "getDerivedStateFromProps",
|
@@ -755,6 +829,10 @@ HiSelect.defaultProps = {
|
|
755
829
|
filterFunc: filterValue
|
756
830
|
};
|
757
831
|
HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
832
|
+
/**
|
833
|
+
* Affiche une alerte à l'ouverture de la liste
|
834
|
+
*/
|
835
|
+
alert: _propTypes.default.object,
|
758
836
|
align: _propTypes.default.oneOf(['left', 'right']),
|
759
837
|
|
760
838
|
/**
|
@@ -41,6 +41,8 @@ var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
|
41
41
|
|
42
42
|
var _keycode = _interopRequireDefault(require("keycode"));
|
43
43
|
|
44
|
+
var _reactDeviceDetect = require("react-device-detect");
|
45
|
+
|
44
46
|
var styles = function styles(theme) {
|
45
47
|
return {
|
46
48
|
root: {
|
@@ -52,6 +54,9 @@ var styles = function styles(theme) {
|
|
52
54
|
padding: 8,
|
53
55
|
cursor: 'pointer'
|
54
56
|
},
|
57
|
+
rootMobile: {
|
58
|
+
backgroundColor: theme.palette.background2
|
59
|
+
},
|
55
60
|
underline: {
|
56
61
|
'&:before': {
|
57
62
|
backgroundColor: theme.palette.input.bottomLine,
|
@@ -257,7 +262,7 @@ function (_React$PureComponent) {
|
|
257
262
|
id = _this$props.id,
|
258
263
|
placeholder = _this$props.placeholder; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
259
264
|
|
260
|
-
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));
|
265
|
+
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), (0, _defineProperty2.default)(_classNames, classes.rootMobile, _reactDeviceDetect.isMobile), _classNames));
|
261
266
|
var iconClass = (0, _classnames.default)(classes.icon, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, classes.iconOpen, open), (0, _defineProperty2.default)(_classNames2, classes.iconClose, !open), _classNames2));
|
262
267
|
return noButton ? _react.default.createElement("div", {
|
263
268
|
id: id,
|
@@ -0,0 +1,198 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = exports.styles = void 0;
|
9
|
+
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
|
+
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
13
|
+
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
15
|
+
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
17
|
+
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
19
|
+
|
20
|
+
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
21
|
+
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
23
|
+
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
25
|
+
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
27
|
+
|
28
|
+
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
29
|
+
|
30
|
+
var styles = function styles(theme) {
|
31
|
+
return {
|
32
|
+
root: {
|
33
|
+
position: 'absolute',
|
34
|
+
opacity: '0',
|
35
|
+
marginTop: -40,
|
36
|
+
height: 40
|
37
|
+
}
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
exports.styles = styles;
|
42
|
+
|
43
|
+
var HiSelectMobile =
|
44
|
+
/*#__PURE__*/
|
45
|
+
function (_React$Component) {
|
46
|
+
(0, _inherits2.default)(HiSelectMobile, _React$Component);
|
47
|
+
|
48
|
+
function HiSelectMobile() {
|
49
|
+
var _getPrototypeOf2;
|
50
|
+
|
51
|
+
var _this;
|
52
|
+
|
53
|
+
(0, _classCallCheck2.default)(this, HiSelectMobile);
|
54
|
+
|
55
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
56
|
+
args[_key] = arguments[_key];
|
57
|
+
}
|
58
|
+
|
59
|
+
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(HiSelectMobile)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
60
|
+
|
61
|
+
_this.buildOptionList = function (itemList) {
|
62
|
+
var optionList = [];
|
63
|
+
|
64
|
+
if (itemList.length) {
|
65
|
+
var parentId;
|
66
|
+
var groupList = [];
|
67
|
+
itemList.forEach(function (item) {
|
68
|
+
if (item.id !== '_all' && item.displayed !== false) {
|
69
|
+
if (item.hasChildren) {
|
70
|
+
if (groupList.length) {
|
71
|
+
optionList.push(_this.buildChildrenList(groupList));
|
72
|
+
groupList = [];
|
73
|
+
}
|
74
|
+
|
75
|
+
parentId = item.id;
|
76
|
+
groupList.push(item);
|
77
|
+
} else if (parentId) {
|
78
|
+
groupList.push(item);
|
79
|
+
} else if (item.children) {
|
80
|
+
optionList.push(_this.buildChildrenList([item].concat((0, _toConsumableArray2.default)(item.children))));
|
81
|
+
} else {
|
82
|
+
optionList.push(_react.default.createElement("option", {
|
83
|
+
key: item.id,
|
84
|
+
"data-item": JSON.stringify(item),
|
85
|
+
value: item.id
|
86
|
+
}, item.label));
|
87
|
+
}
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
if (groupList.length) {
|
92
|
+
optionList.push(_this.buildChildrenList(groupList));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
return optionList;
|
97
|
+
};
|
98
|
+
|
99
|
+
_this.buildChildrenList = function (itemList) {
|
100
|
+
var group = itemList.shift();
|
101
|
+
return _react.default.createElement("optgroup", {
|
102
|
+
key: group.id,
|
103
|
+
label: group.label
|
104
|
+
}, itemList.map(function (item) {
|
105
|
+
return _react.default.createElement("option", {
|
106
|
+
key: item.id,
|
107
|
+
"data-item": JSON.stringify(item),
|
108
|
+
value: item.id
|
109
|
+
}, item.label);
|
110
|
+
}));
|
111
|
+
};
|
112
|
+
|
113
|
+
_this.handleChange = function (event) {
|
114
|
+
if (!_this.props.multiple) {
|
115
|
+
var itemSelected = event.target[event.target.selectedIndex];
|
116
|
+
|
117
|
+
_this.props.onChange(event, JSON.parse(itemSelected.getAttribute('data-item')));
|
118
|
+
} else {
|
119
|
+
// Multiple on mobile trigger on change with all selected items
|
120
|
+
var optionsSelected = [];
|
121
|
+
Array.prototype.forEach.call(event.target.options, function (option) {
|
122
|
+
if (option.selected) {
|
123
|
+
optionsSelected.push(JSON.parse(option.getAttribute('data-item')));
|
124
|
+
}
|
125
|
+
});
|
126
|
+
|
127
|
+
_this.props.onChange(event, optionsSelected);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
return _this;
|
132
|
+
}
|
133
|
+
|
134
|
+
(0, _createClass2.default)(HiSelectMobile, [{
|
135
|
+
key: "render",
|
136
|
+
value: function render() {
|
137
|
+
var _this$props = this.props,
|
138
|
+
classes = _this$props.classes,
|
139
|
+
id = _this$props.id,
|
140
|
+
itemList = _this$props.itemList,
|
141
|
+
multiple = _this$props.multiple,
|
142
|
+
value = _this$props.value;
|
143
|
+
var additionalProps = (0, _extends2.default)({}, multiple && {
|
144
|
+
multiple: 'multiple'
|
145
|
+
});
|
146
|
+
return _react.default.createElement("select", (0, _extends2.default)({
|
147
|
+
value: value,
|
148
|
+
style: {
|
149
|
+
width: this.props.width
|
150
|
+
},
|
151
|
+
onChange: this.handleChange,
|
152
|
+
className: classes.root,
|
153
|
+
name: id,
|
154
|
+
id: id
|
155
|
+
}, additionalProps), this.buildOptionList(itemList));
|
156
|
+
}
|
157
|
+
}]);
|
158
|
+
return HiSelectMobile;
|
159
|
+
}(_react.default.Component);
|
160
|
+
|
161
|
+
HiSelectMobile.defaultProps = {
|
162
|
+
itemList: []
|
163
|
+
};
|
164
|
+
HiSelectMobile.propTypes = process.env.NODE_ENV !== "production" ? {
|
165
|
+
/**
|
166
|
+
* Identifiant du select
|
167
|
+
*/
|
168
|
+
id: _propTypes.default.string,
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Liste des options du select
|
172
|
+
*/
|
173
|
+
itemList: _propTypes.default.array.isRequired,
|
174
|
+
|
175
|
+
/**
|
176
|
+
* True s'il est possible de sélectionner plusieurs options
|
177
|
+
*/
|
178
|
+
multiple: _propTypes.default.bool,
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Fonction appelée lors de la sélection/désélection
|
182
|
+
*/
|
183
|
+
onChange: _propTypes.default.func.isRequired,
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Valeur(s) sélectionnée(s)
|
187
|
+
*/
|
188
|
+
value: _propTypes.default.any,
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Largeur du select
|
192
|
+
*/
|
193
|
+
width: _propTypes.default.number
|
194
|
+
} : {};
|
195
|
+
|
196
|
+
var _default = (0, _withStyles.default)(styles)(HiSelectMobile);
|
197
|
+
|
198
|
+
exports.default = _default;
|
@@ -115,7 +115,7 @@ class HiAlertModal extends React.PureComponent {
|
|
115
115
|
color: theme.palette.background2,
|
116
116
|
icon: backgroundIcon,
|
117
117
|
size: iconSize
|
118
|
-
})), React.createElement(DialogTitle, {
|
118
|
+
})), title && React.createElement(DialogTitle, {
|
119
119
|
disableTypography: true,
|
120
120
|
classes: {
|
121
121
|
root: classes.classTitle
|