@hipay/hipay-material-ui 2.0.0-beta.74 → 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 +153 -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/HiNotice/HiKPI.js +14 -8
- package/HiPaymentMeans/HiPaymentMeans.js +2 -1
- 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/HiNotice/HiKPI.js +13 -8
- package/es/HiPaymentMeans/HiPaymentMeans.js +2 -1
- 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 +2 -1
- package/styles/createPalette.js +1 -1
@@ -0,0 +1,127 @@
|
|
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 = void 0;
|
9
|
+
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
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 _getPrototypeOf2 = _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 _HiFormControl = _interopRequireDefault(require("../HiForm/HiFormControl"));
|
29
|
+
|
30
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
31
|
+
|
32
|
+
var _stylesheet = _interopRequireDefault(require("./stylesheet"));
|
33
|
+
|
34
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
35
|
+
|
36
|
+
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
37
|
+
|
38
|
+
var _HiInput = _interopRequireDefault(require("../HiForm/HiInput"));
|
39
|
+
|
40
|
+
var HiDatePickerMobile =
|
41
|
+
/*#__PURE__*/
|
42
|
+
function (_React$Component) {
|
43
|
+
(0, _inherits2.default)(HiDatePickerMobile, _React$Component);
|
44
|
+
|
45
|
+
function HiDatePickerMobile() {
|
46
|
+
(0, _classCallCheck2.default)(this, HiDatePickerMobile);
|
47
|
+
return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiDatePickerMobile).apply(this, arguments));
|
48
|
+
}
|
49
|
+
|
50
|
+
(0, _createClass2.default)(HiDatePickerMobile, [{
|
51
|
+
key: "render",
|
52
|
+
value: function render() {
|
53
|
+
var _this$props = this.props,
|
54
|
+
classes = _this$props.classes,
|
55
|
+
id = _this$props.id,
|
56
|
+
label = _this$props.label,
|
57
|
+
required = _this$props.required,
|
58
|
+
disabled = _this$props.disabled,
|
59
|
+
error = _this$props.error,
|
60
|
+
errorText = _this$props.errorText,
|
61
|
+
helperIcon = _this$props.helperIcon,
|
62
|
+
helperText = _this$props.helperText,
|
63
|
+
enableTime = _this$props.enableTime,
|
64
|
+
value = _this$props.value,
|
65
|
+
disablePastDays = _this$props.disablePastDays,
|
66
|
+
disableFutureDays = _this$props.disableFutureDays,
|
67
|
+
minimumDate = _this$props.minimumDate,
|
68
|
+
today = _this$props.today,
|
69
|
+
range = _this$props.range,
|
70
|
+
format = _this$props.format;
|
71
|
+
var addtionalProps = (0, _extends2.default)({}, this.props.disabled && {
|
72
|
+
disabled: "disabled"
|
73
|
+
});
|
74
|
+
return _react.default.createElement(_HiFormControl.default, {
|
75
|
+
id: id,
|
76
|
+
label: label,
|
77
|
+
required: required,
|
78
|
+
disabled: disabled,
|
79
|
+
error: error,
|
80
|
+
errorText: errorText,
|
81
|
+
helperText: helperText,
|
82
|
+
helperIcon: helperIcon
|
83
|
+
}, _react.default.createElement(_HiInput.default, {
|
84
|
+
inputId: id,
|
85
|
+
name: id,
|
86
|
+
type: "text",
|
87
|
+
placeholder: this.props.placeholder,
|
88
|
+
value: !value ? '' : (0, _momentTimezone.default)(value).format(format),
|
89
|
+
disabled: disabled
|
90
|
+
}), _react.default.createElement("input", (0, _extends2.default)({
|
91
|
+
className: (0, _classnames.default)(classes.root, classes.rootMobile, (0, _defineProperty2.default)({}, classes.mobileRangeRoot, range)),
|
92
|
+
id: id,
|
93
|
+
type: enableTime ? "datetime-local" : "date",
|
94
|
+
value: !value ? '' : enableTime ? (0, _momentTimezone.default)(value).format('YYYY-MM-DDTHH:mm') : (0, _momentTimezone.default)(value).format('YYYY-MM-DD'),
|
95
|
+
onChange: this.props.onChange,
|
96
|
+
min: disablePastDays ? today.format('YYYY-MM-DD') : minimumDate ? (0, _momentTimezone.default)(minimumDate).format('YYYY-MM-DD') : '',
|
97
|
+
max: disableFutureDays ? today.format('YYYY-MM-DD') : ''
|
98
|
+
}, addtionalProps)));
|
99
|
+
}
|
100
|
+
}]);
|
101
|
+
return HiDatePickerMobile;
|
102
|
+
}(_react.default.Component);
|
103
|
+
|
104
|
+
HiDatePickerMobile.propTypes = process.env.NODE_ENV !== "production" ? {
|
105
|
+
classes: _propTypes.default.object,
|
106
|
+
disabled: _propTypes.default.bool,
|
107
|
+
disableFutureDays: _propTypes.default.bool,
|
108
|
+
disablePastDays: _propTypes.default.bool,
|
109
|
+
enableTime: _propTypes.default.bool,
|
110
|
+
error: _propTypes.default.bool,
|
111
|
+
errorText: _propTypes.default.string,
|
112
|
+
format: _propTypes.default.string,
|
113
|
+
helperIcon: _propTypes.default.string,
|
114
|
+
helperText: _propTypes.default.string,
|
115
|
+
id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
116
|
+
label: _propTypes.default.string,
|
117
|
+
minimumDate: _propTypes.default.any,
|
118
|
+
onChange: _propTypes.default.func,
|
119
|
+
range: _propTypes.default.bool,
|
120
|
+
required: _propTypes.default.bool,
|
121
|
+
today: _propTypes.default.any,
|
122
|
+
value: _propTypes.default.any
|
123
|
+
} : {};
|
124
|
+
|
125
|
+
var _default = (0, _withStyles.default)(_stylesheet.default)(HiDatePickerMobile);
|
126
|
+
|
127
|
+
exports.default = _default;
|
@@ -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/HiNotice/HiKPI.js
CHANGED
@@ -31,6 +31,8 @@ var _styles = require("../styles");
|
|
31
31
|
|
32
32
|
var _ButtonBase = _interopRequireDefault(require("@material-ui/core/ButtonBase"));
|
33
33
|
|
34
|
+
var _Collapse = _interopRequireDefault(require("@material-ui/core/Collapse"));
|
35
|
+
|
34
36
|
var styles = function styles(theme) {
|
35
37
|
return {
|
36
38
|
root: {
|
@@ -74,32 +76,32 @@ var styles = function styles(theme) {
|
|
74
76
|
boxShadow: 'none'
|
75
77
|
},
|
76
78
|
body: {
|
77
|
-
height: '100%',
|
78
79
|
margin: 0,
|
79
80
|
display: 'inline-grid',
|
80
81
|
alignItems: 'center',
|
81
82
|
fontSize: 20,
|
82
|
-
fontWeight: theme.typography.fontWeightLight
|
83
|
+
fontWeight: theme.typography.fontWeightLight,
|
84
|
+
flex: '1 1 auto'
|
83
85
|
},
|
84
86
|
title: {
|
85
|
-
height: '100%',
|
86
87
|
maxHeight: 16,
|
87
88
|
maxWidth: '100%',
|
88
89
|
margin: '7px 0px',
|
89
90
|
whiteSpace: 'nowrap',
|
90
91
|
overflow: 'hidden',
|
91
92
|
fontSize: 14,
|
92
|
-
fontWeight: theme.typography.fontWeightLight
|
93
|
+
fontWeight: theme.typography.fontWeightLight,
|
94
|
+
flex: '0 1 16px'
|
93
95
|
},
|
94
96
|
subtitle: {
|
95
|
-
height: '100%',
|
96
97
|
maxHeight: 28,
|
97
98
|
margin: '2px 0px',
|
98
99
|
maxWidth: '100%',
|
99
100
|
color: theme.palette.neutral.main,
|
100
101
|
fontSize: 11,
|
101
102
|
lineHeight: '13px',
|
102
|
-
fontWeight: theme.typography.fontWeightMedium
|
103
|
+
fontWeight: theme.typography.fontWeightMedium,
|
104
|
+
flex: '0 1 28px'
|
103
105
|
},
|
104
106
|
minify: {
|
105
107
|
height: 72
|
@@ -148,7 +150,11 @@ function (_React$Component) {
|
|
148
150
|
tooltip = _this$props.tooltip,
|
149
151
|
disable = _this$props.disable;
|
150
152
|
var rootclass = (0, _classnames.default)(classes.root, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.inherit, color === 'inherit' && !disable), (0, _defineProperty2.default)(_classNames, classes.warning, color === 'warning' && !disable), (0, _defineProperty2.default)(_classNames, classes.error, color === 'error' && !disable), (0, _defineProperty2.default)(_classNames, classes.positive, color === 'positive' && !disable), (0, _defineProperty2.default)(_classNames, classes.active, active), (0, _defineProperty2.default)(_classNames, classes.minify, minify), _classNames));
|
151
|
-
return _react.default.createElement(
|
153
|
+
return _react.default.createElement(_Collapse.default, {
|
154
|
+
in: !minify,
|
155
|
+
timeout: "auto",
|
156
|
+
collapsedHeight: "88px"
|
157
|
+
}, _react.default.createElement(_ButtonBase.default, {
|
152
158
|
className: rootclass,
|
153
159
|
onClick: !disable ? this.handleClick(id) : undefined,
|
154
160
|
title: tooltip
|
@@ -158,7 +164,7 @@ function (_React$Component) {
|
|
158
164
|
className: classes.body
|
159
165
|
}, minify && bodyMinify ? bodyMinify : body), subtitle && minify === false && _react.default.createElement("div", {
|
160
166
|
className: classes.subtitle
|
161
|
-
}, subtitle));
|
167
|
+
}, subtitle)));
|
162
168
|
}
|
163
169
|
}]);
|
164
170
|
return HiKPI;
|
@@ -348,6 +348,7 @@ function (_React$Component) {
|
|
348
348
|
username = "".concat(translations.gender_male, " ").concat(cardUser);
|
349
349
|
}
|
350
350
|
|
351
|
+
var creditDebit = translations.credit && translations.debit && (credit ? translations.credit : translations.debit).toUpperCase();
|
351
352
|
var cardLayout;
|
352
353
|
|
353
354
|
switch (type) {
|
@@ -467,7 +468,7 @@ function (_React$Component) {
|
|
467
468
|
className: (0, _classnames.default)(classes.labelLarge, classes.userNameSepa)
|
468
469
|
}, username), _react.default.createElement("div", {
|
469
470
|
className: (0, _classnames.default)(classes.labelLarge, classes.labelDebitCredit)
|
470
|
-
},
|
471
|
+
}, creditDebit));
|
471
472
|
break;
|
472
473
|
|
473
474
|
case 'prepaid-card':
|
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,
|