@hipay/hipay-material-ui 2.0.0-beta.54 → 2.0.0-beta.56
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +57 -0
- package/HiBreadcrumb/HiBreadcrumb.js +14 -4
- package/HiBreadcrumb/HiStep.js +4 -1
- package/HiBreadcrumb/HiStepContent.js +0 -1
- package/HiBreadcrumb/HiStepLabel.js +12 -4
- package/HiBreadcrumb/HiStepper.js +1 -1
- package/HiButton/HiButton.js +7 -1
- package/HiCell/CellIcon.js +4 -4
- package/HiCell/CellImage.js +28 -4
- package/HiCell/CellNumeric.js +1 -2
- package/HiCell/CellRate.js +6 -3
- package/HiCell/CellSentinel.js +7 -10
- package/HiCell/CellSentinelScore.js +4 -4
- package/HiCell/CellTextStyled.js +99 -0
- package/HiCell/index.js +9 -1
- package/HiChip/HiChip.js +1 -0
- package/HiDatePicker/Caption.js +8 -9
- package/HiDatePicker/HiDateRangePicker.js +37 -19
- package/HiDatePicker/HiDateRangeSelector.js +24 -22
- package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
- package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
- package/HiDatePicker/Overlays/Overlay.js +15 -8
- package/HiDatePicker/Overlays/Overlay.spec.js +1 -0
- package/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
- package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
- package/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
- package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/HiDatePicker/stylesheet.js +3 -2
- package/HiDotsStepper/HiDot.js +108 -0
- package/HiDotsStepper/HiDotsStepper.js +121 -0
- package/HiExpansionPanel/HiExpansionPanel.js +1 -1
- package/HiForm/HiAddressField.js +176 -0
- package/HiForm/HiSlider.js +352 -0
- package/HiForm/HiUpload.js +204 -0
- package/HiForm/HiUploadField.js +182 -0
- package/HiForm/HiUploadInput.js +459 -0
- package/HiForm/index.js +16 -0
- package/HiMap/HiMap.js +345 -0
- package/HiMap/HiMapExpand.js +210 -0
- package/HiMap/index.js +23 -0
- package/HiNotice/HiKPI.js +238 -0
- package/HiNotice/HiKPINotice.js +93 -0
- package/HiNotice/index.js +23 -0
- package/HiPdfReader/HiPdfReader.js +269 -0
- package/HiPdfReader/index.js +15 -0
- package/HiRadio/HiRadio.js +74 -0
- package/HiRadio/index.js +15 -0
- package/HiSelect/HiSelect.js +73 -84
- package/HiSelect/HiSuggestSelect.js +32 -5
- package/HiSelect/SelectInput.js +5 -0
- package/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/HiSelectNew/HiSelect.js +174 -137
- package/HiSelectNew/HiSelectContent.js +0 -8
- package/HiSelectNew/HiSelectInput.js +8 -9
- package/HiSelectableList/HiSelectableList.js +32 -4
- package/HiSelectableList/HiSelectableListItem.js +62 -24
- package/HiTable/HiCellBuilder.js +42 -32
- package/HiTable/HiTableHeader.js +28 -21
- package/HiTable/constants.js +3 -1
- package/README.md +249 -98
- package/es/HiBreadcrumb/HiBreadcrumb.js +14 -4
- package/es/HiBreadcrumb/HiStep.js +4 -1
- package/es/HiBreadcrumb/HiStepContent.js +0 -1
- package/es/HiBreadcrumb/HiStepLabel.js +13 -4
- package/es/HiBreadcrumb/HiStepper.js +1 -1
- package/es/HiButton/HiButton.js +7 -0
- package/es/HiCell/CellIcon.js +5 -5
- package/es/HiCell/CellImage.js +25 -2
- package/es/HiCell/CellNumeric.js +1 -2
- package/es/HiCell/CellRate.js +6 -3
- package/es/HiCell/CellSentinel.js +7 -10
- package/es/HiCell/CellSentinelScore.js +4 -4
- package/es/HiCell/CellTextStyled.js +84 -0
- package/es/HiCell/index.js +2 -1
- package/es/HiChip/HiChip.js +1 -0
- package/es/HiDatePicker/Caption.js +7 -9
- package/es/HiDatePicker/HiDateRangePicker.js +41 -25
- package/es/HiDatePicker/HiDateRangeSelector.js +24 -22
- package/es/HiDatePicker/ListPicker.js +1 -1
- package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +2 -2
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/Overlay.js +16 -9
- package/es/HiDatePicker/Overlays/Overlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
- package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
- package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/stylesheet.js +3 -2
- package/es/HiDotsStepper/HiDot.js +66 -0
- package/es/HiDotsStepper/HiDotsStepper.js +73 -0
- package/es/HiExpansionPanel/HiExpansionPanel.js +1 -1
- package/es/HiForm/HiAddressField.js +134 -0
- package/es/HiForm/HiSlider.js +302 -0
- package/es/HiForm/HiUpload.js +158 -0
- package/es/HiForm/HiUploadField.js +140 -0
- package/es/HiForm/HiUploadInput.js +411 -0
- package/es/HiForm/index.js +2 -0
- package/es/HiMap/HiMap.js +290 -0
- package/es/HiMap/HiMapExpand.js +162 -0
- package/es/HiMap/index.js +2 -0
- package/es/HiNotice/HiKPI.js +196 -0
- package/es/HiNotice/HiKPINotice.js +77 -0
- package/es/HiNotice/index.js +2 -0
- package/es/HiPdfReader/HiPdfReader.js +214 -0
- package/es/HiPdfReader/index.js +1 -0
- package/es/HiRadio/HiRadio.js +55 -0
- package/es/HiRadio/index.js +1 -0
- package/es/HiSelect/HiSelect.js +68 -78
- package/es/HiSelect/HiSuggestSelect.js +27 -6
- package/es/HiSelect/SelectInput.js +5 -0
- package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/es/HiSelectNew/HiSelect.js +156 -120
- package/es/HiSelectNew/HiSelectContent.js +0 -7
- package/es/HiSelectNew/HiSelectInput.js +8 -9
- package/es/HiSelectableList/HiSelectableList.js +28 -6
- package/es/HiSelectableList/HiSelectableListItem.js +71 -24
- package/es/HiTable/HiCellBuilder.js +140 -136
- package/es/HiTable/HiTableHeader.js +26 -18
- package/es/HiTable/constants.js +1 -0
- package/es/index.js +7 -0
- package/es/utils/helpers.js +1 -1
- package/index.es.js +8 -1
- package/index.js +57 -1
- package/package.json +6 -3
- package/umd/hipay-material-ui.development.js +42114 -35120
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +1 -1
@@ -7,10 +7,15 @@ import Paper from '@material-ui/core/Paper';
|
|
7
7
|
import withStyles from '../../styles/withStyles';
|
8
8
|
export const styles = theme => ({
|
9
9
|
paper: {
|
10
|
-
position: 'absolute',
|
11
10
|
width: '100%',
|
12
11
|
zIndex: 10
|
13
12
|
},
|
13
|
+
absolute: {
|
14
|
+
position: 'absolute'
|
15
|
+
},
|
16
|
+
relative: {
|
17
|
+
position: 'relative'
|
18
|
+
},
|
14
19
|
left: {
|
15
20
|
width: '200%',
|
16
21
|
left: 0
|
@@ -56,30 +61,35 @@ const CustomOverlayLayout = (_ref) => {
|
|
56
61
|
headerElement,
|
57
62
|
footerElement,
|
58
63
|
absoluteElement,
|
59
|
-
side
|
64
|
+
side,
|
65
|
+
staticPosition
|
60
66
|
} = _ref,
|
61
|
-
props = _objectWithoutProperties(_ref, ["classes", "children", "headerElement", "footerElement", "absoluteElement", "side"]);
|
67
|
+
props = _objectWithoutProperties(_ref, ["classes", "children", "headerElement", "footerElement", "absoluteElement", "side", "staticPosition"]);
|
62
68
|
|
63
69
|
const paperClass = classNames(classes.paper, {
|
64
70
|
[classes.left]: side === 'from',
|
65
|
-
[classes.right]: side === 'to'
|
71
|
+
[classes.right]: side === 'to',
|
72
|
+
[classes.absolute]: staticPosition !== true,
|
73
|
+
[classes.relative]: staticPosition === true
|
66
74
|
});
|
67
75
|
|
68
|
-
|
76
|
+
const paperProps = _objectSpread({}, props);
|
69
77
|
|
70
|
-
return
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
return (// eslint-disable-next-line react/jsx-handler-names
|
79
|
+
React.createElement(Paper, {
|
80
|
+
className: paperClass,
|
81
|
+
onBlur: paperProps.onBlur,
|
82
|
+
onFocus: paperProps.onFocus
|
83
|
+
}, React.createElement("div", {
|
84
|
+
className: classes.overlay
|
85
|
+
}, React.createElement("div", {
|
86
|
+
className: classes.header
|
87
|
+
}, headerElement), React.createElement("div", {
|
88
|
+
className: classes.body
|
89
|
+
}, children), React.createElement("div", {
|
90
|
+
className: classes.footer
|
91
|
+
}, footerElement), absoluteElement))
|
92
|
+
);
|
83
93
|
};
|
84
94
|
|
85
95
|
CustomOverlayLayout.propTypes = process.env.NODE_ENV !== "production" ? {
|
@@ -96,7 +106,8 @@ CustomOverlayLayout.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
96
106
|
/**
|
97
107
|
* Définit comment construire le Paper dans le cas d'un double input
|
98
108
|
*/
|
99
|
-
side: PropTypes.string
|
109
|
+
side: PropTypes.string,
|
110
|
+
staticPosition: PropTypes.bool
|
100
111
|
} : {};
|
101
112
|
export default withStyles(styles, {
|
102
113
|
name: 'HmuiCustomOverlayLayout'
|
@@ -31,8 +31,8 @@ class MonthPickerOverlay extends React.Component {
|
|
31
31
|
} = _this$props,
|
32
32
|
props = _objectWithoutProperties(_this$props, ["value", "translations"]);
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
const now = new Date();
|
35
|
+
const currentMonth = props.localeUtils ? props.localeUtils.getMonths()[now.getMonth()] : props.children.props.localeUtils.getMonths()[now.getMonth()];
|
36
36
|
return React.createElement(CustomOverlayLayout, _extends({
|
37
37
|
headerElement: translations.month
|
38
38
|
}, props), React.createElement(ListPicker, {
|
@@ -45,15 +45,17 @@ const Overlay = (_ref) => {
|
|
45
45
|
[classes.relative]: staticPosition === true
|
46
46
|
});
|
47
47
|
|
48
|
-
|
48
|
+
const paperProps = _objectSpread({}, props);
|
49
49
|
|
50
|
-
return
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
return (// eslint-disable-next-line react/jsx-handler-names
|
51
|
+
React.createElement(Paper, {
|
52
|
+
onBlur: paperProps.onBlur,
|
53
|
+
onFocus: paperProps.onFocus,
|
54
|
+
className: paperClass
|
55
|
+
}, React.createElement("div", {
|
56
|
+
className: classes.overlay
|
57
|
+
}, children))
|
58
|
+
);
|
57
59
|
};
|
58
60
|
|
59
61
|
Overlay.propTypes = process.env.NODE_ENV !== "production" ? {
|
@@ -88,7 +90,12 @@ Overlay.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
88
90
|
/**
|
89
91
|
* Définit comment construire le Paper dans le cas d'un double input
|
90
92
|
*/
|
91
|
-
side: PropTypes.string
|
93
|
+
side: PropTypes.string,
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Display overlay with position static
|
97
|
+
*/
|
98
|
+
staticPosition: PropTypes.bool
|
92
99
|
} : {};
|
93
100
|
export default withStyles(styles, {
|
94
101
|
name: 'HmuiOverlay'
|
@@ -81,7 +81,7 @@ export const styles = theme => ({
|
|
81
81
|
bottom: 0,
|
82
82
|
height: 32,
|
83
83
|
width: 32,
|
84
|
-
margin: '
|
84
|
+
margin: '4px 24px'
|
85
85
|
},
|
86
86
|
calendarButton: {
|
87
87
|
fontWeight: theme.typography.fontWeightMedium
|
@@ -92,7 +92,7 @@ var _ref = React.createElement(CalendarIcon, null);
|
|
92
92
|
|
93
93
|
class TimePickerOverlay extends React.Component {
|
94
94
|
constructor(props) {
|
95
|
-
super();
|
95
|
+
super(props);
|
96
96
|
this.hours = Array.from(Array(24).keys());
|
97
97
|
this.minutes = Array.from(Array(60).keys());
|
98
98
|
this.handleHourClick = this.handleHourClick.bind(this);
|
@@ -7,7 +7,7 @@ import ListPicker from '../ListPicker';
|
|
7
7
|
|
8
8
|
class YearPickerOverlay extends React.Component {
|
9
9
|
constructor(props) {
|
10
|
-
super();
|
10
|
+
super(props);
|
11
11
|
this.years = [];
|
12
12
|
this.handleYearClick = this.handleYearClick.bind(this);
|
13
13
|
const currentYear = new Date().getFullYear();
|
@@ -55,8 +55,6 @@ class YearPickerOverlay extends React.Component {
|
|
55
55
|
}
|
56
56
|
|
57
57
|
YearPickerOverlay.defaultProps = {
|
58
|
-
// disableFutureDays: true,
|
59
|
-
// disablePastDays: false,
|
60
58
|
minimumDate: new Date(2013, 4, 1),
|
61
59
|
// by default 1 May 2013
|
62
60
|
translations: {
|
@@ -92,7 +90,7 @@ YearPickerOverlay.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
92
90
|
/**
|
93
91
|
* Date minimale sélectionnable
|
94
92
|
*/
|
95
|
-
minimumDate: PropTypes.instanceOf(Date)
|
93
|
+
minimumDate: PropTypes.instanceOf(Date),
|
96
94
|
|
97
95
|
/**
|
98
96
|
* Fonction de callback
|
@@ -161,7 +161,7 @@ export default (theme => ({
|
|
161
161
|
// Added to the day's cell for the current day
|
162
162
|
today: {
|
163
163
|
// color: theme.palette.primary.light,
|
164
|
-
|
164
|
+
boxShadow: 'inset 0 0 0 2px #8b9898',
|
165
165
|
borderRadius: '50%',
|
166
166
|
color: `${theme.palette.neutral.dark} !important`,
|
167
167
|
fontWeight: theme.typography.fontWeightMedium
|
@@ -169,7 +169,8 @@ export default (theme => ({
|
|
169
169
|
// Added to the day's cell outside the current month
|
170
170
|
outside: {
|
171
171
|
backgroundColor: '#F8F9FB',
|
172
|
-
color: theme.palette.neutral.main
|
172
|
+
color: theme.palette.neutral.main,
|
173
|
+
cursor: 'default'
|
173
174
|
},
|
174
175
|
// Added to the day's cell specified in the "disabledDays" prop
|
175
176
|
disabled: {
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
import React from 'react';
|
4
|
+
import PropTypes from 'prop-types';
|
5
|
+
import withStyles from '../styles/withStyles';
|
6
|
+
import HiIcon from '../HiIcon';
|
7
|
+
import HiIconButton from '../HiIconButton';
|
8
|
+
export const styles = () => ({
|
9
|
+
dot: {
|
10
|
+
padding: 4,
|
11
|
+
'&:hover': {
|
12
|
+
backgroundColor: 'transparent !important'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
var _ref = React.createElement(HiIcon, {
|
18
|
+
size: 24
|
19
|
+
}, "radio_button_checked");
|
20
|
+
|
21
|
+
var _ref2 = React.createElement(HiIcon, {
|
22
|
+
size: 12
|
23
|
+
}, "lens");
|
24
|
+
|
25
|
+
class HiDot extends React.PureComponent {
|
26
|
+
render() {
|
27
|
+
const _this$props = this.props,
|
28
|
+
{
|
29
|
+
active,
|
30
|
+
status,
|
31
|
+
classes,
|
32
|
+
onClick
|
33
|
+
} = _this$props,
|
34
|
+
props = _objectWithoutProperties(_this$props, ["active", "status", "classes", "onClick"]);
|
35
|
+
|
36
|
+
let dotColor;
|
37
|
+
|
38
|
+
if (!status || status === 'unreviewed') {
|
39
|
+
dotColor = 'default';
|
40
|
+
} else {
|
41
|
+
dotColor = status === 'refused' ? 'negative' : 'positive';
|
42
|
+
}
|
43
|
+
|
44
|
+
return React.createElement(HiIconButton, _extends({
|
45
|
+
className: classes.dot,
|
46
|
+
color: dotColor,
|
47
|
+
onClick: onClick
|
48
|
+
}, props), active ? _ref : _ref2);
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
HiDot.defaultProps = {
|
54
|
+
active: false,
|
55
|
+
status: 'unreviewed'
|
56
|
+
};
|
57
|
+
HiDot.propTypes = process.env.NODE_ENV !== "production" ? {
|
58
|
+
active: PropTypes.bool,
|
59
|
+
classes: PropTypes.object,
|
60
|
+
onClick: PropTypes.func,
|
61
|
+
status: PropTypes.oneOf(['refused', 'validated', 'unreviewed'])
|
62
|
+
} : {};
|
63
|
+
export default withStyles(styles, {
|
64
|
+
hiComponent: true,
|
65
|
+
name: 'HmuiHiDot'
|
66
|
+
})(HiDot);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import withStyles from '../styles/withStyles';
|
4
|
+
import HiDot from './HiDot';
|
5
|
+
export const styles = () => ({
|
6
|
+
dotStepper: {
|
7
|
+
width: '100%',
|
8
|
+
maxWidth: 200,
|
9
|
+
display: 'flex',
|
10
|
+
flexDirection: 'row',
|
11
|
+
flexWrap: 'nowrap',
|
12
|
+
justifyContent: 'center',
|
13
|
+
alignItems: 'center'
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
class HiDotsStepper extends React.PureComponent {
|
18
|
+
constructor(props) {
|
19
|
+
super(props);
|
20
|
+
|
21
|
+
this.handleClick = activeStep => () => {
|
22
|
+
this.props.onChange(activeStep);
|
23
|
+
};
|
24
|
+
|
25
|
+
this.handleNavigation = e => {
|
26
|
+
const {
|
27
|
+
activeStep,
|
28
|
+
steps
|
29
|
+
} = this.props;
|
30
|
+
let nextStep = activeStep;
|
31
|
+
if (e.key === 'ArrowLeft') nextStep -= 1;
|
32
|
+
if (e.key === 'ArrowRight') nextStep += 1;
|
33
|
+
nextStep = (nextStep + steps.length) % steps.length; // Permet la navigation d'un Dot au suivant / précédent
|
34
|
+
|
35
|
+
document.querySelector(`button[tabIndex="${nextStep}"]`).focus();
|
36
|
+
this.props.onChange(nextStep);
|
37
|
+
};
|
38
|
+
|
39
|
+
this.handleClick = this.handleClick.bind(this);
|
40
|
+
this.handleNavigation = this.handleNavigation.bind(this);
|
41
|
+
}
|
42
|
+
|
43
|
+
render() {
|
44
|
+
const {
|
45
|
+
classes,
|
46
|
+
activeStep,
|
47
|
+
steps
|
48
|
+
} = this.props;
|
49
|
+
return React.createElement("div", {
|
50
|
+
role: "presentation",
|
51
|
+
className: classes.dotStepper,
|
52
|
+
onKeyDown: this.handleNavigation
|
53
|
+
}, steps.map((step, idx) => React.createElement(HiDot, {
|
54
|
+
key: step.id,
|
55
|
+
tabIndex: step.id,
|
56
|
+
status: step.status,
|
57
|
+
active: idx === activeStep,
|
58
|
+
onClick: this.handleClick(idx)
|
59
|
+
})));
|
60
|
+
}
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
HiDotsStepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
65
|
+
activeStep: PropTypes.number.isRequired,
|
66
|
+
classes: PropTypes.object,
|
67
|
+
onChange: PropTypes.func,
|
68
|
+
steps: PropTypes.array.isRequired
|
69
|
+
} : {};
|
70
|
+
export default withStyles(styles, {
|
71
|
+
hiComponent: true,
|
72
|
+
name: 'HmuiHiDotsStepper'
|
73
|
+
})(HiDotsStepper);
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
// @inheritedComponent HiSuggestSelectField
|
4
|
+
import React from 'react';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import HiSuggestSelectField from '../HiSelect/HiSuggestSelectField'; // OpenStreeMap API url
|
7
|
+
|
8
|
+
const API_URL = 'https://nominatim.openstreetmap.org/search?q=';
|
9
|
+
/**
|
10
|
+
* Champs input adresse pour formulaire
|
11
|
+
*/
|
12
|
+
|
13
|
+
class HiAddressField extends React.Component {
|
14
|
+
constructor(props) {
|
15
|
+
super(props);
|
16
|
+
|
17
|
+
this.displaySuggestions = predictions => {
|
18
|
+
const options = [];
|
19
|
+
let isExact = false;
|
20
|
+
predictions.forEach(prediction => {
|
21
|
+
// Si le texte saisi est identique à une des propositions, on estime que la valeur de l'adresse est exacte.
|
22
|
+
isExact = prediction.display_name === this.state.inputValue ? true : isExact;
|
23
|
+
options.push({
|
24
|
+
id: prediction.place_id,
|
25
|
+
label: prediction.display_name,
|
26
|
+
labelHighlight: prediction.display_name.replace(new RegExp(this.value, 'gi'), '<strong>$&</strong>'),
|
27
|
+
// Liste des types d'adresse : https://github.com/openstreetmap/Nominatim/blob/80df4d3b560f5b1fd550dcf8cdc09a992b69fee0/settings/partitionedtags.def
|
28
|
+
icon: ['amenity', 'building'].includes(prediction.category) ? 'domain' : 'place',
|
29
|
+
type: 'icon',
|
30
|
+
key: prediction.id
|
31
|
+
});
|
32
|
+
}, this);
|
33
|
+
this.setState({
|
34
|
+
options,
|
35
|
+
isExact
|
36
|
+
});
|
37
|
+
};
|
38
|
+
|
39
|
+
this.state = {
|
40
|
+
inputValue: null,
|
41
|
+
options: [],
|
42
|
+
isExact: false
|
43
|
+
};
|
44
|
+
this.handleSearch = this.handleSearch.bind(this);
|
45
|
+
this.handleSelect = this.handleSelect.bind(this);
|
46
|
+
this.handleReset = this.handleReset.bind(this);
|
47
|
+
this.displaySuggestions = this.displaySuggestions.bind(this);
|
48
|
+
}
|
49
|
+
|
50
|
+
handleSearch(event) {
|
51
|
+
if (event.target.value) {
|
52
|
+
this.setState({
|
53
|
+
inputValue: event.target.value
|
54
|
+
});
|
55
|
+
fetch(`${API_URL} + ${this.state.inputValue} + &format=jsonv2&limit=5&bounded=1&dedupe=1&namedetails=1`).then(result => result.json()).then(data => {
|
56
|
+
this.displaySuggestions(data, 'OK');
|
57
|
+
});
|
58
|
+
} else {
|
59
|
+
this.setState({
|
60
|
+
options: []
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
this.props.onSearch(event);
|
65
|
+
}
|
66
|
+
|
67
|
+
handleReset() {
|
68
|
+
this.props.onReset();
|
69
|
+
this.setState({
|
70
|
+
options: [],
|
71
|
+
isExact: false
|
72
|
+
});
|
73
|
+
}
|
74
|
+
|
75
|
+
handleSelect(event, value) {
|
76
|
+
// Mise à jour de la valeur du champ + la valeur de l'adresse est exacte
|
77
|
+
this.setState({
|
78
|
+
options: [],
|
79
|
+
isExact: true
|
80
|
+
});
|
81
|
+
this.props.onSelect(event, value.label);
|
82
|
+
}
|
83
|
+
|
84
|
+
render() {
|
85
|
+
const _this$props = this.props,
|
86
|
+
{
|
87
|
+
exactOnly,
|
88
|
+
onSearch,
|
89
|
+
onReset,
|
90
|
+
onSelect
|
91
|
+
} = _this$props,
|
92
|
+
otherProps = _objectWithoutProperties(_this$props, ["exactOnly", "onSearch", "onReset", "onSelect"]);
|
93
|
+
|
94
|
+
const {
|
95
|
+
options,
|
96
|
+
isExact
|
97
|
+
} = this.state; // On met le champ en erreur si une adresse exacte est éxigée
|
98
|
+
// et si l'adresse courante n'est pas complète
|
99
|
+
|
100
|
+
const showError = exactOnly && !isExact;
|
101
|
+
return React.createElement(HiSuggestSelectField, _extends({
|
102
|
+
error: showError,
|
103
|
+
options: options,
|
104
|
+
onSearch: this.handleSearch,
|
105
|
+
onSelect: this.handleSelect,
|
106
|
+
onReset: this.handleReset,
|
107
|
+
isExact: isExact
|
108
|
+
}, otherProps));
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
HiAddressField.propTypes = process.env.NODE_ENV !== "production" ? {
|
114
|
+
/**
|
115
|
+
* Est-ce qu'on n'accepte que les adresses trouvées par GMaps
|
116
|
+
*/
|
117
|
+
exactOnly: PropTypes.bool,
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Callback function called to empty the field.
|
121
|
+
*/
|
122
|
+
onReset: PropTypes.func,
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Callback function called when we write in the input.
|
126
|
+
*/
|
127
|
+
onSearch: PropTypes.func,
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Callback function called when a suggestion is selected.
|
131
|
+
*/
|
132
|
+
onSelect: PropTypes.func
|
133
|
+
} : {};
|
134
|
+
export default HiAddressField;
|