@hipay/hipay-material-ui 1.0.0-beta.8 → 1.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HiDotsStepper/HiDot.js +151 -0
- package/HiDotsStepper/HiDotsStepper.js +146 -0
- package/HiDotsStepper/index.js +16 -0
- package/HiForm/HiAddressField.js +204 -0
- package/HiForm/HiInput.js +1 -1
- package/HiForm/index.js +9 -0
- package/HiPdfReader/HiPdfReader.js +282 -0
- package/HiPdfReader/index.js +16 -0
- package/HiSelect/HiSuggestSelect.js +2 -0
- package/HiSelectableList/HiSelectableListItem.js +1 -2
- package/HiTable/BodyCellBuilder.js +7 -8
- package/HiTable/BodyCells/CellLayout.js +20 -18
- package/HiTable/BodyCells/CellSentinel.js +12 -4
- package/HiTable/BodyRow.js +7 -1
- package/HiTable/HeaderCell.js +17 -14
- package/HiTable/HiTable.js +13 -4
- package/HiTable/HiTableBody.js +26 -12
- package/HiTable/HiTableHead.js +22 -5
- package/es/HiDotsStepper/HiDot.js +92 -0
- package/es/HiDotsStepper/HiDotsStepper.js +83 -0
- package/es/HiDotsStepper/index.js +1 -0
- package/es/HiForm/HiAddressField.js +142 -0
- package/es/HiForm/HiInput.js +1 -1
- package/es/HiForm/index.js +2 -1
- package/es/HiPdfReader/HiPdfReader.js +198 -0
- package/es/HiPdfReader/index.js +1 -0
- package/es/HiSelect/HiSuggestSelect.js +2 -0
- package/es/HiSelectableList/HiSelectableListItem.js +1 -2
- package/es/HiTable/BodyCellBuilder.js +8 -9
- package/es/HiTable/BodyCells/CellLayout.js +22 -20
- package/es/HiTable/BodyCells/CellSentinel.js +12 -4
- package/es/HiTable/BodyRow.js +7 -1
- package/es/HiTable/HeaderCell.js +17 -14
- package/es/HiTable/HiTable.js +13 -4
- package/es/HiTable/HiTableBody.js +22 -9
- package/es/HiTable/HiTableHead.js +17 -5
- package/es/styles/createHiMuiTheme.js +7 -0
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -1
- package/styles/createHiMuiTheme.js +7 -0
- package/umd/hipay-material-ui.development.js +2874 -2606
- package/umd/hipay-material-ui.production.min.js +4 -4
package/HiTable/HiTableBody.js
CHANGED
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.styles = undefined;
|
7
7
|
|
8
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
9
|
+
|
10
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
11
|
+
|
8
12
|
var _extends2 = require('babel-runtime/helpers/extends');
|
9
13
|
|
10
14
|
var _extends3 = _interopRequireDefault(_extends2);
|
@@ -43,6 +47,10 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
43
47
|
|
44
48
|
var _Table = require('material-ui/Table');
|
45
49
|
|
50
|
+
var _classnames = require('classnames');
|
51
|
+
|
52
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
53
|
+
|
46
54
|
var _styles = require('../styles');
|
47
55
|
|
48
56
|
var _BodyRow = require('./BodyRow');
|
@@ -61,12 +69,6 @@ var _constants = require('./constants');
|
|
61
69
|
|
62
70
|
var cst = _interopRequireWildcard(_constants);
|
63
71
|
|
64
|
-
var _HiTableHead = require('./HiTableHead');
|
65
|
-
|
66
|
-
var _reactProptypeConditionalRequire = require('react-proptype-conditional-require');
|
67
|
-
|
68
|
-
var _reactProptypeConditionalRequire2 = _interopRequireDefault(_reactProptypeConditionalRequire);
|
69
|
-
|
70
72
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
71
73
|
|
72
74
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -75,12 +77,14 @@ var styles = exports.styles = function styles(theme) {
|
|
75
77
|
return {
|
76
78
|
tbody: {
|
77
79
|
position: 'relative',
|
78
|
-
|
79
|
-
, width: '100%',
|
80
|
+
width: '100%',
|
80
81
|
overflowX: 'hidden',
|
81
82
|
overflowY: 'auto',
|
82
83
|
zIndex: 11
|
83
84
|
},
|
85
|
+
tbodyFixedWidth: {
|
86
|
+
display: 'block' /* seperates the tbody from the header */
|
87
|
+
},
|
84
88
|
tbodyRows: {
|
85
89
|
backgroundColor: theme.palette.background3
|
86
90
|
},
|
@@ -282,7 +286,8 @@ var HiTableBody = function (_React$Component) {
|
|
282
286
|
groupByIds = _props.groupByIds,
|
283
287
|
sortedColumnId = _props.sortedColumnId,
|
284
288
|
lookupColumns = _props.lookupColumns,
|
285
|
-
loading = _props.loading
|
289
|
+
loading = _props.loading,
|
290
|
+
fixedColumnWidth = _props.fixedColumnWidth;
|
286
291
|
var _state = this.state,
|
287
292
|
openedParentRowId = _state.openedParentRowId,
|
288
293
|
openedDetailsRowIdList = _state.openedDetailsRowIdList;
|
@@ -380,7 +385,8 @@ var HiTableBody = function (_React$Component) {
|
|
380
385
|
row: row,
|
381
386
|
sticky: sticky,
|
382
387
|
tabId: tabId,
|
383
|
-
view: view
|
388
|
+
view: view,
|
389
|
+
fixedColumnWidth: fixedColumnWidth
|
384
390
|
});
|
385
391
|
|
386
392
|
if (hasChildren && openedParentRowId === row.rowId) {
|
@@ -409,7 +415,8 @@ var HiTableBody = function (_React$Component) {
|
|
409
415
|
view: view,
|
410
416
|
dense: dense,
|
411
417
|
sticky: sticky,
|
412
|
-
isDetail: true
|
418
|
+
isDetail: true,
|
419
|
+
fixedColumnWidth: fixedColumnWidth
|
413
420
|
};
|
414
421
|
|
415
422
|
tableRows.push(_react2.default.createElement(_BodyRow2.default, (0, _extends3.default)({ key: row.rowId + '-' + detailRow.rowId }, detailRowProps)));
|
@@ -417,11 +424,13 @@ var HiTableBody = function (_React$Component) {
|
|
417
424
|
}
|
418
425
|
});
|
419
426
|
|
427
|
+
var tBodyClasses = (0, _classnames2.default)(classes.tbody, (0, _defineProperty3.default)({}, classes.tbodyFixedWidth, fixedColumnWidth));
|
428
|
+
|
420
429
|
return _react2.default.createElement(
|
421
430
|
_Table.TableBody,
|
422
431
|
{
|
423
432
|
id: tabId + '-body',
|
424
|
-
className:
|
433
|
+
className: tBodyClasses,
|
425
434
|
style: (0, _extends3.default)({
|
426
435
|
height: height
|
427
436
|
}, loading && {
|
@@ -476,6 +485,11 @@ HiTableBody.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
476
485
|
* Densité d'affichage (joue sur la hauteur des lignes)
|
477
486
|
*/
|
478
487
|
dense: _propTypes2.default.bool,
|
488
|
+
/**
|
489
|
+
* Fixe la taille des colonnes selon le type de vue
|
490
|
+
* Sinon les colonnes s'adaptent à l'espace disponible
|
491
|
+
*/
|
492
|
+
fixedColumnWidth: _propTypes2.default.bool,
|
479
493
|
/**
|
480
494
|
* Hauteur du tableau (px)
|
481
495
|
*/
|
package/HiTable/HiTableHead.js
CHANGED
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.SORTED_COLUMN_ERROR_MESSAGE = exports.styles = undefined;
|
7
7
|
|
8
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
9
|
+
|
10
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
11
|
+
|
8
12
|
var _extends2 = require('babel-runtime/helpers/extends');
|
9
13
|
|
10
14
|
var _extends3 = _interopRequireDefault(_extends2);
|
@@ -43,6 +47,10 @@ var _reactProptypeConditionalRequire = require('react-proptype-conditional-requi
|
|
43
47
|
|
44
48
|
var _reactProptypeConditionalRequire2 = _interopRequireDefault(_reactProptypeConditionalRequire);
|
45
49
|
|
50
|
+
var _classnames = require('classnames');
|
51
|
+
|
52
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
53
|
+
|
46
54
|
var _Table = require('material-ui/Table');
|
47
55
|
|
48
56
|
var _PlusCircle = require('mdi-material-ui/PlusCircle');
|
@@ -79,11 +87,13 @@ var styles = exports.styles = function styles(theme) {
|
|
79
87
|
return {
|
80
88
|
thead: {
|
81
89
|
position: 'relative',
|
82
|
-
|
83
|
-
, width: '100%',
|
90
|
+
width: '100%',
|
84
91
|
overflow: 'visible',
|
85
92
|
zIndex: 12
|
86
93
|
},
|
94
|
+
theadFixedWidth: {
|
95
|
+
display: 'block' /*seperates the header from the body allowing it to be positioned*/
|
96
|
+
},
|
87
97
|
theadRow: {
|
88
98
|
backgroundColor: theme.palette.background3,
|
89
99
|
zIndex: 12
|
@@ -226,7 +236,8 @@ var HiTableHead = function (_React$Component) {
|
|
226
236
|
sticky = _props.sticky,
|
227
237
|
translations = _props.translations,
|
228
238
|
view = _props.view,
|
229
|
-
lookupColumns = _props.lookupColumns
|
239
|
+
lookupColumns = _props.lookupColumns,
|
240
|
+
fixedColumnWidth = _props.fixedColumnWidth;
|
230
241
|
var _state = this.state,
|
231
242
|
hovered = _state.hovered,
|
232
243
|
openedOrderColumns = _state.openedOrderColumns,
|
@@ -234,7 +245,7 @@ var HiTableHead = function (_React$Component) {
|
|
234
245
|
|
235
246
|
|
236
247
|
var headerProps = (0, _extends3.default)({
|
237
|
-
className: classes.thead
|
248
|
+
className: (0, _classnames2.default)(classes.thead, (0, _defineProperty3.default)({}, classes.theadFixedWidth, fixedColumnWidth))
|
238
249
|
}, orderable && { onMouseEnter: this.handleEvent, onMouseLeave: this.handleEvent });
|
239
250
|
|
240
251
|
var unfixedColumnIsSet = false,
|
@@ -301,7 +312,8 @@ var HiTableHead = function (_React$Component) {
|
|
301
312
|
fixedWidth: fixed,
|
302
313
|
align: column['align'],
|
303
314
|
sticky: firstColumn && sticky,
|
304
|
-
lookedUp: lookupColumns.includes(column.colId)
|
315
|
+
lookedUp: lookupColumns.includes(column.colId),
|
316
|
+
fixedColumnWidth: fixedColumnWidth
|
305
317
|
});
|
306
318
|
}
|
307
319
|
}),
|
@@ -411,6 +423,11 @@ HiTableHead.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
411
423
|
* Active le filtre sur les colonnes filtrables
|
412
424
|
*/
|
413
425
|
filterable: _propTypes2.default.bool,
|
426
|
+
/**
|
427
|
+
* Fixe la taille des colonnes selon le type de vue
|
428
|
+
* Sinon les colonnes s'adaptent à l'espace disponible
|
429
|
+
*/
|
430
|
+
fixedColumnWidth: _propTypes2.default.bool,
|
414
431
|
/**
|
415
432
|
* Identifiant de la ou des colonnes sur la/lesquelles il y a une 'lookup' search
|
416
433
|
*/
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import classnames from 'classnames';
|
4
|
+
import withStyles from '../styles/withStyles';
|
5
|
+
import ButtonBase from '../ButtonBase';
|
6
|
+
|
7
|
+
export const styles = theme => ({
|
8
|
+
dot: {
|
9
|
+
backgroundColor: theme.palette.dot.neutral,
|
10
|
+
borderRadius: '100%',
|
11
|
+
width: 12,
|
12
|
+
height: 12,
|
13
|
+
'&:hover': {
|
14
|
+
transform: 'scale(1.2)'
|
15
|
+
},
|
16
|
+
marginLeft: 12
|
17
|
+
},
|
18
|
+
dotActive: {
|
19
|
+
marginTop: 4,
|
20
|
+
marginLeft: 4,
|
21
|
+
'&:hover': {
|
22
|
+
transform: 'scale(1)'
|
23
|
+
}
|
24
|
+
},
|
25
|
+
dotValidated: {
|
26
|
+
backgroundColor: theme.palette.status[116]
|
27
|
+
},
|
28
|
+
dotRefused: {
|
29
|
+
backgroundColor: theme.palette.error.main
|
30
|
+
},
|
31
|
+
dotAround: {
|
32
|
+
backgroundColor: 'transparent',
|
33
|
+
borderRadius: '100%',
|
34
|
+
width: 24,
|
35
|
+
height: 24,
|
36
|
+
marginLeft: 6,
|
37
|
+
border: '2px solid ' + theme.palette.dot.neutral,
|
38
|
+
'&:hover': {
|
39
|
+
transform: 'scale(1.2)'
|
40
|
+
}
|
41
|
+
},
|
42
|
+
dotAroundValidated: {
|
43
|
+
border: '2px solid ' + theme.palette.status[116]
|
44
|
+
},
|
45
|
+
dotAroundRefused: {
|
46
|
+
border: '2px solid ' + theme.palette.error.main
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
class HiDot extends React.PureComponent {
|
51
|
+
|
52
|
+
render() {
|
53
|
+
const { active, status, classes, onClick } = this.props;
|
54
|
+
|
55
|
+
const dotAroundClass = classnames(classes.dotAround, {
|
56
|
+
[classes.dotAroundValidated]: status === 'validated',
|
57
|
+
[classes.dotAroundRefused]: status === 'refused'
|
58
|
+
});
|
59
|
+
|
60
|
+
const dotClassName = classnames(classes.dot, {
|
61
|
+
[classes.dotActive]: active,
|
62
|
+
[classes.dotRefused]: status === 'refused',
|
63
|
+
[classes.dotValidated]: status === 'validated'
|
64
|
+
});
|
65
|
+
|
66
|
+
return React.createElement(
|
67
|
+
ButtonBase,
|
68
|
+
{ disableRipple: true, role: 'button', onClick: onClick },
|
69
|
+
active ? React.createElement(
|
70
|
+
'div',
|
71
|
+
{ className: dotAroundClass },
|
72
|
+
React.createElement('div', { className: dotClassName })
|
73
|
+
) : React.createElement('div', { className: dotClassName })
|
74
|
+
);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
HiDot.defaultProps = {
|
79
|
+
active: false,
|
80
|
+
status: 'unreviewed'
|
81
|
+
};
|
82
|
+
HiDot.propTypes = process.env.NODE_ENV !== "production" ? {
|
83
|
+
active: PropTypes.bool,
|
84
|
+
classes: PropTypes.object,
|
85
|
+
/**
|
86
|
+
* @ignore
|
87
|
+
*/
|
88
|
+
className: PropTypes.string,
|
89
|
+
onClick: PropTypes.func,
|
90
|
+
status: PropTypes.oneOf(['refused', 'validated', 'unreviewed'])
|
91
|
+
} : {};
|
92
|
+
export default withStyles(styles, { name: 'MuiHiDot' })(HiDot);
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import withStyles from '../styles/withStyles';
|
4
|
+
import HiDot from './HiDot';
|
5
|
+
|
6
|
+
export const styles = theme => ({
|
7
|
+
dotStepper: {
|
8
|
+
width: '100%',
|
9
|
+
maxWidth: 200,
|
10
|
+
display: 'flex',
|
11
|
+
flexDirection: 'row',
|
12
|
+
flexWrap: 'nowrap',
|
13
|
+
justifyContent: 'center',
|
14
|
+
alignItems: 'center'
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
class HiDotsStepper extends React.PureComponent {
|
19
|
+
|
20
|
+
constructor() {
|
21
|
+
super();
|
22
|
+
|
23
|
+
this.handleClick = activeStep => () => {
|
24
|
+
this.props.onChange(activeStep);
|
25
|
+
};
|
26
|
+
|
27
|
+
this.handleNavigation = activeStep => e => {
|
28
|
+
let nextStep = activeStep;
|
29
|
+
const { steps } = this.props;
|
30
|
+
|
31
|
+
if (e.key === 'ArrowLeft') nextStep -= 1;
|
32
|
+
if (e.key === 'ArrowRight') nextStep += 1;
|
33
|
+
|
34
|
+
nextStep = (nextStep + steps.length) % steps.length;
|
35
|
+
|
36
|
+
// Permet la navigation d'un Dot au suivant / précédent
|
37
|
+
document.querySelector(`div[tabIndex="${nextStep}"]`).focus();
|
38
|
+
|
39
|
+
this.props.onChange(nextStep);
|
40
|
+
};
|
41
|
+
|
42
|
+
this.handleClick = this.handleClick.bind(this);
|
43
|
+
this.handleNavigation = this.handleNavigation.bind(this);
|
44
|
+
}
|
45
|
+
|
46
|
+
render() {
|
47
|
+
const { classes, activeStep, steps } = this.props;
|
48
|
+
|
49
|
+
const listDots = steps.map((step, idx) => {
|
50
|
+
const { id, status } = step;
|
51
|
+
return React.createElement(
|
52
|
+
'div',
|
53
|
+
{
|
54
|
+
key: id,
|
55
|
+
tabIndex: id,
|
56
|
+
className: classes.dotContainer,
|
57
|
+
role: 'navigation',
|
58
|
+
onKeyDown: this.handleNavigation(idx)
|
59
|
+
},
|
60
|
+
React.createElement(HiDot, {
|
61
|
+
status: status,
|
62
|
+
active: idx === activeStep,
|
63
|
+
onClick: this.handleClick(idx)
|
64
|
+
})
|
65
|
+
);
|
66
|
+
});
|
67
|
+
|
68
|
+
return React.createElement(
|
69
|
+
'div',
|
70
|
+
{ className: classes.dotStepper },
|
71
|
+
listDots
|
72
|
+
);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
HiDotsStepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
77
|
+
activeStep: PropTypes.number.isRequired,
|
78
|
+
classes: PropTypes.object,
|
79
|
+
className: PropTypes.string,
|
80
|
+
onChange: PropTypes.func,
|
81
|
+
steps: PropTypes.array.isRequired
|
82
|
+
} : {};
|
83
|
+
export default withStyles(styles, { name: 'MuiHiDotsStepper' })(HiDotsStepper);
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './HiDotsStepper';
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
2
|
+
import _extends from 'babel-runtime/helpers/extends';
|
3
|
+
// @inheritedComponent HiSuggestSelectField
|
4
|
+
|
5
|
+
import React from 'react';
|
6
|
+
import PropTypes from 'prop-types';
|
7
|
+
import HiSuggestSelectField from '../HiSelect/HiSuggestSelectField';
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Champs input adresse pour formulaire
|
11
|
+
*/
|
12
|
+
class HiAddressField extends React.Component {
|
13
|
+
constructor(props) {
|
14
|
+
super(props);
|
15
|
+
this.autocompleteService = null;
|
16
|
+
|
17
|
+
this.displaySuggestions = (predictions, status) => {
|
18
|
+
if (status !== 'OK') {
|
19
|
+
// Si l'API renvoie un statut différent de 'OK'
|
20
|
+
// (par exemple ZERO_RESULTS), pas de prédictions
|
21
|
+
} else {
|
22
|
+
// Sinon je mets à jour les options du champ avec les prédictions de GMaps
|
23
|
+
const options = [];
|
24
|
+
let isExact = false;
|
25
|
+
predictions.forEach(prediction => {
|
26
|
+
// Si le texte saisi est identique à une des propositions de GMaps,
|
27
|
+
// on estime que la valeur de l'adresse est exacte,
|
28
|
+
// même sans clic sur une proposition
|
29
|
+
isExact = prediction.description === this.value ? true : isExact;
|
30
|
+
options.push({
|
31
|
+
id: prediction.id,
|
32
|
+
label: prediction.description,
|
33
|
+
labelHighlight: prediction.description.replace(new RegExp(this.value, 'gi'), '<strong>$&</strong>'),
|
34
|
+
icon: prediction.types.indexOf('establishment') >= 0 ? 'domain' : 'map_marker',
|
35
|
+
type: 'icon'
|
36
|
+
});
|
37
|
+
}, this);
|
38
|
+
this.setState({ options, isExact });
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
this.state = {
|
43
|
+
options: [],
|
44
|
+
isExact: false
|
45
|
+
};
|
46
|
+
|
47
|
+
this.handleSearch = this.handleSearch.bind(this);
|
48
|
+
this.handleSelect = this.handleSelect.bind(this);
|
49
|
+
this.handleReset = this.handleReset.bind(this);
|
50
|
+
this.displaySuggestions = this.displaySuggestions.bind(this);
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Au chargement du composant, je définis mon service autocomplete GMaps
|
55
|
+
*/
|
56
|
+
componentDidMount() {
|
57
|
+
this.autocompleteService = new google.maps.places.AutocompleteService();
|
58
|
+
}
|
59
|
+
|
60
|
+
handleReset() {
|
61
|
+
this.props.onReset();
|
62
|
+
this.setState({
|
63
|
+
options: [],
|
64
|
+
isExact: false
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
handleSearch(event) {
|
69
|
+
// Je vérifie que le champ n'est pas vide car l'API lève une exception en cas d'input vide
|
70
|
+
if (event.target.value) {
|
71
|
+
// Liste des types à rechercher. Voir https://developers.google.com/places/web-service/autocomplete?hl=fr#place_types (ex : ['establishement', 'address']
|
72
|
+
const types = [];
|
73
|
+
// Liste des codes ISO Alpha-2 des pays où il faut rechercher (ex : ['fr', 'us'])
|
74
|
+
const countries = [];
|
75
|
+
// À chaque changement, la méthode getPlacesPredictions appelle la méthode
|
76
|
+
// displaySuggestions en lui fournissant un tableau de 5 prédictions
|
77
|
+
this.value = event.target.value;
|
78
|
+
if (this.autocompleteService) {
|
79
|
+
this.autocompleteService.getPlacePredictions({
|
80
|
+
input: event.target.value,
|
81
|
+
types,
|
82
|
+
componentRestrictions: { country: countries }
|
83
|
+
}, this.displaySuggestions);
|
84
|
+
} else {
|
85
|
+
// Dans le cas où le service ne peut pas se charger (mode test par exemple).
|
86
|
+
this.displaySuggestions([], 'EMPTY_RESULT');
|
87
|
+
}
|
88
|
+
}
|
89
|
+
this.props.onSearch(event);
|
90
|
+
// Mise à jour du texte dans l'input
|
91
|
+
this.setState(_extends({}, !event.target.value && {
|
92
|
+
options: []
|
93
|
+
}));
|
94
|
+
}
|
95
|
+
|
96
|
+
handleSelect(event, value) {
|
97
|
+
// Mise à jour de la valeur du champ + la valeur de l'adresse est exacte
|
98
|
+
this.setState({ options: [], isExact: true });
|
99
|
+
this.props.onSelect(event, value.label);
|
100
|
+
}
|
101
|
+
|
102
|
+
render() {
|
103
|
+
const _props = this.props,
|
104
|
+
{ exactOnly, onSearch, onReset, onSelect } = _props,
|
105
|
+
otherProps = _objectWithoutProperties(_props, ['exactOnly', 'onSearch', 'onReset', 'onSelect']);
|
106
|
+
const { options, isExact } = this.state;
|
107
|
+
|
108
|
+
// On met le champ en erreur si une adresse exacte est éxigée
|
109
|
+
// et si l'adresse courante n'est pas complète
|
110
|
+
const showError = exactOnly && !isExact;
|
111
|
+
|
112
|
+
return React.createElement(HiSuggestSelectField, _extends({
|
113
|
+
options: options,
|
114
|
+
onSearch: this.handleSearch,
|
115
|
+
onReset: this.handleReset,
|
116
|
+
onSelect: this.handleSelect,
|
117
|
+
isExact: isExact,
|
118
|
+
error: showError
|
119
|
+
}, otherProps));
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
HiAddressField.propTypes = process.env.NODE_ENV !== "production" ? {
|
124
|
+
/**
|
125
|
+
* Est-ce qu'on n'accepte que les adresses trouvées par GMaps
|
126
|
+
*/
|
127
|
+
exactOnly: PropTypes.bool,
|
128
|
+
/**
|
129
|
+
* Callback function called to empty the field.
|
130
|
+
*/
|
131
|
+
onReset: PropTypes.func,
|
132
|
+
/**
|
133
|
+
* Callback function called when we write in the input.
|
134
|
+
*/
|
135
|
+
onSearch: PropTypes.func,
|
136
|
+
/**
|
137
|
+
* Callback function called when a suggestion is selected.
|
138
|
+
*/
|
139
|
+
onSelect: PropTypes.func
|
140
|
+
} : {};
|
141
|
+
|
142
|
+
export default HiAddressField;
|
package/es/HiForm/HiInput.js
CHANGED
package/es/HiForm/index.js
CHANGED
@@ -4,4 +4,5 @@ export { default as HiFormLabel } from './HiFormLabel';
|
|
4
4
|
export { default as HiInput } from './HiInput';
|
5
5
|
export { default as HiPasswordField } from './HiPasswordField';
|
6
6
|
export { default as HiTextField } from './HiTextField';
|
7
|
-
export { default as HiSearchField } from './HiSearchField';
|
7
|
+
export { default as HiSearchField } from './HiSearchField';
|
8
|
+
export { default as HiAddressField } from './HiAddressField';
|