@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.
Files changed (128) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/HiBreadcrumb/HiBreadcrumb.js +14 -4
  3. package/HiBreadcrumb/HiStep.js +4 -1
  4. package/HiBreadcrumb/HiStepContent.js +0 -1
  5. package/HiBreadcrumb/HiStepLabel.js +12 -4
  6. package/HiBreadcrumb/HiStepper.js +1 -1
  7. package/HiButton/HiButton.js +7 -1
  8. package/HiCell/CellIcon.js +4 -4
  9. package/HiCell/CellImage.js +28 -4
  10. package/HiCell/CellNumeric.js +1 -2
  11. package/HiCell/CellRate.js +6 -3
  12. package/HiCell/CellSentinel.js +7 -10
  13. package/HiCell/CellSentinelScore.js +4 -4
  14. package/HiCell/CellTextStyled.js +99 -0
  15. package/HiCell/index.js +9 -1
  16. package/HiChip/HiChip.js +1 -0
  17. package/HiDatePicker/Caption.js +8 -9
  18. package/HiDatePicker/HiDateRangePicker.js +37 -19
  19. package/HiDatePicker/HiDateRangeSelector.js +24 -22
  20. package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
  21. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  22. package/HiDatePicker/Overlays/Overlay.js +15 -8
  23. package/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  24. package/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  25. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  26. package/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
  27. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  28. package/HiDatePicker/stylesheet.js +3 -2
  29. package/HiDotsStepper/HiDot.js +108 -0
  30. package/HiDotsStepper/HiDotsStepper.js +121 -0
  31. package/HiExpansionPanel/HiExpansionPanel.js +1 -1
  32. package/HiForm/HiAddressField.js +176 -0
  33. package/HiForm/HiSlider.js +352 -0
  34. package/HiForm/HiUpload.js +204 -0
  35. package/HiForm/HiUploadField.js +182 -0
  36. package/HiForm/HiUploadInput.js +459 -0
  37. package/HiForm/index.js +16 -0
  38. package/HiMap/HiMap.js +345 -0
  39. package/HiMap/HiMapExpand.js +210 -0
  40. package/HiMap/index.js +23 -0
  41. package/HiNotice/HiKPI.js +238 -0
  42. package/HiNotice/HiKPINotice.js +93 -0
  43. package/HiNotice/index.js +23 -0
  44. package/HiPdfReader/HiPdfReader.js +269 -0
  45. package/HiPdfReader/index.js +15 -0
  46. package/HiRadio/HiRadio.js +74 -0
  47. package/HiRadio/index.js +15 -0
  48. package/HiSelect/HiSelect.js +73 -84
  49. package/HiSelect/HiSuggestSelect.js +32 -5
  50. package/HiSelect/SelectInput.js +5 -0
  51. package/HiSelectNew/HiNestedSelectContent.js +5 -1
  52. package/HiSelectNew/HiSelect.js +174 -137
  53. package/HiSelectNew/HiSelectContent.js +0 -8
  54. package/HiSelectNew/HiSelectInput.js +8 -9
  55. package/HiSelectableList/HiSelectableList.js +32 -4
  56. package/HiSelectableList/HiSelectableListItem.js +62 -24
  57. package/HiTable/HiCellBuilder.js +42 -32
  58. package/HiTable/HiTableHeader.js +28 -21
  59. package/HiTable/constants.js +3 -1
  60. package/README.md +249 -98
  61. package/es/HiBreadcrumb/HiBreadcrumb.js +14 -4
  62. package/es/HiBreadcrumb/HiStep.js +4 -1
  63. package/es/HiBreadcrumb/HiStepContent.js +0 -1
  64. package/es/HiBreadcrumb/HiStepLabel.js +13 -4
  65. package/es/HiBreadcrumb/HiStepper.js +1 -1
  66. package/es/HiButton/HiButton.js +7 -0
  67. package/es/HiCell/CellIcon.js +5 -5
  68. package/es/HiCell/CellImage.js +25 -2
  69. package/es/HiCell/CellNumeric.js +1 -2
  70. package/es/HiCell/CellRate.js +6 -3
  71. package/es/HiCell/CellSentinel.js +7 -10
  72. package/es/HiCell/CellSentinelScore.js +4 -4
  73. package/es/HiCell/CellTextStyled.js +84 -0
  74. package/es/HiCell/index.js +2 -1
  75. package/es/HiChip/HiChip.js +1 -0
  76. package/es/HiDatePicker/Caption.js +7 -9
  77. package/es/HiDatePicker/HiDateRangePicker.js +41 -25
  78. package/es/HiDatePicker/HiDateRangeSelector.js +24 -22
  79. package/es/HiDatePicker/ListPicker.js +1 -1
  80. package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
  81. package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +2 -2
  82. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  83. package/es/HiDatePicker/Overlays/Overlay.js +16 -9
  84. package/es/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  85. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  86. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  87. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
  88. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  89. package/es/HiDatePicker/stylesheet.js +3 -2
  90. package/es/HiDotsStepper/HiDot.js +66 -0
  91. package/es/HiDotsStepper/HiDotsStepper.js +73 -0
  92. package/es/HiExpansionPanel/HiExpansionPanel.js +1 -1
  93. package/es/HiForm/HiAddressField.js +134 -0
  94. package/es/HiForm/HiSlider.js +302 -0
  95. package/es/HiForm/HiUpload.js +158 -0
  96. package/es/HiForm/HiUploadField.js +140 -0
  97. package/es/HiForm/HiUploadInput.js +411 -0
  98. package/es/HiForm/index.js +2 -0
  99. package/es/HiMap/HiMap.js +290 -0
  100. package/es/HiMap/HiMapExpand.js +162 -0
  101. package/es/HiMap/index.js +2 -0
  102. package/es/HiNotice/HiKPI.js +196 -0
  103. package/es/HiNotice/HiKPINotice.js +77 -0
  104. package/es/HiNotice/index.js +2 -0
  105. package/es/HiPdfReader/HiPdfReader.js +214 -0
  106. package/es/HiPdfReader/index.js +1 -0
  107. package/es/HiRadio/HiRadio.js +55 -0
  108. package/es/HiRadio/index.js +1 -0
  109. package/es/HiSelect/HiSelect.js +68 -78
  110. package/es/HiSelect/HiSuggestSelect.js +27 -6
  111. package/es/HiSelect/SelectInput.js +5 -0
  112. package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
  113. package/es/HiSelectNew/HiSelect.js +156 -120
  114. package/es/HiSelectNew/HiSelectContent.js +0 -7
  115. package/es/HiSelectNew/HiSelectInput.js +8 -9
  116. package/es/HiSelectableList/HiSelectableList.js +28 -6
  117. package/es/HiSelectableList/HiSelectableListItem.js +71 -24
  118. package/es/HiTable/HiCellBuilder.js +140 -136
  119. package/es/HiTable/HiTableHeader.js +26 -18
  120. package/es/HiTable/constants.js +1 -0
  121. package/es/index.js +7 -0
  122. package/es/utils/helpers.js +1 -1
  123. package/index.es.js +8 -1
  124. package/index.js +57 -1
  125. package/package.json +6 -3
  126. package/umd/hipay-material-ui.development.js +42114 -35120
  127. package/umd/hipay-material-ui.production.min.js +2 -2
  128. 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
- let paperProps = _objectSpread({}, props);
76
+ const paperProps = _objectSpread({}, props);
69
77
 
70
- return React.createElement(Paper, {
71
- className: paperClass,
72
- onBlur: paperProps.onBlur,
73
- onFocus: paperProps.onFocus
74
- }, React.createElement("div", {
75
- className: classes.overlay
76
- }, React.createElement("div", {
77
- className: classes.header
78
- }, headerElement), React.createElement("div", {
79
- className: classes.body
80
- }, children), React.createElement("div", {
81
- className: classes.footer
82
- }, footerElement), absoluteElement));
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
- let now = new Date();
35
- let currentMonth = props.localeUtils ? props.localeUtils.getMonths()[now.getMonth()] : props.children.props.localeUtils.getMonths()[now.getMonth()];
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, {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable */
1
2
  import React from 'react';
2
3
  import { assert } from 'chai';
3
4
  import { spy } from 'sinon';
@@ -45,15 +45,17 @@ const Overlay = (_ref) => {
45
45
  [classes.relative]: staticPosition === true
46
46
  });
47
47
 
48
- let paperProps = _objectSpread({}, props);
48
+ const paperProps = _objectSpread({}, props);
49
49
 
50
- return React.createElement(Paper, {
51
- onBlur: paperProps.onBlur,
52
- onFocus: paperProps.onFocus,
53
- className: paperClass
54
- }, React.createElement("div", {
55
- className: classes.overlay
56
- }, children));
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'
@@ -1,3 +1,4 @@
1
+ /* eslint-disable */
1
2
  import React from 'react';
2
3
  import { assert } from 'chai';
3
4
  import { createShallow, getClasses } from '../../test-utils/index';
@@ -81,7 +81,7 @@ export const styles = theme => ({
81
81
  bottom: 0,
82
82
  height: 32,
83
83
  width: 32,
84
- margin: '0px 24px'
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);
@@ -1,3 +1,4 @@
1
+ /* eslint-disable */
1
2
  import React from 'react';
2
3
  import { assert } from 'chai';
3
4
  import { spy } from 'sinon';
@@ -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).isRequired,
93
+ minimumDate: PropTypes.instanceOf(Date),
96
94
 
97
95
  /**
98
96
  * Fonction de callback
@@ -1,3 +1,4 @@
1
+ /* eslint-disable */
1
2
  import React from 'react';
2
3
  import { assert } from 'chai';
3
4
  import { spy } from 'sinon';
@@ -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
- border: '2px solid #8b9898',
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);
@@ -114,7 +114,7 @@ HiExpansionPanel.propTypes = process.env.NODE_ENV !== "production" ? {
114
114
  /**
115
115
  * Titre principal du panel
116
116
  */
117
- heading: PropTypes.string.isRequired,
117
+ heading: PropTypes.any,
118
118
 
119
119
  /**
120
120
  * Titre secondaire du panel
@@ -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;