@hipay/hipay-material-ui 2.0.0-beta.55 → 2.0.0-beta.57

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.
Files changed (137) hide show
  1. package/CHANGELOG.md +116 -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 +13 -1
  10. package/HiCell/CellRate.js +6 -3
  11. package/HiCell/CellSentinel.js +7 -10
  12. package/HiCell/CellTextStyled.js +29 -1
  13. package/HiColoredLabel/HiColoredLabel.js +1 -1
  14. package/HiDatePicker/Caption.js +16 -10
  15. package/HiDatePicker/HiDatePicker.js +9 -3
  16. package/HiDatePicker/HiDateRangePicker.js +36 -22
  17. package/HiDatePicker/HiDateRangeSelector.js +75 -21
  18. package/HiDatePicker/NavBar.js +8 -1
  19. package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
  20. package/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +123 -0
  21. package/HiDatePicker/Overlays/MonthPickerOverlay.js +4 -4
  22. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  23. package/HiDatePicker/Overlays/Overlay.js +15 -8
  24. package/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  25. package/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  26. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  27. package/HiDatePicker/Overlays/YearPickerOverlay.js +4 -6
  28. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  29. package/HiDatePicker/hiLocaleUtils.js +144 -0
  30. package/HiDatePicker/stylesheet.js +33 -7
  31. package/HiDotsStepper/HiDot.js +108 -0
  32. package/HiDotsStepper/HiDotsStepper.js +121 -0
  33. package/HiExpansionPanel/HiExpansionPanel.js +1 -1
  34. package/HiForm/HiAddressField.js +176 -0
  35. package/HiForm/HiFormControl.js +2 -0
  36. package/HiForm/HiInput.js +3 -3
  37. package/HiForm/HiSlider.js +352 -0
  38. package/HiForm/HiUpload.js +204 -0
  39. package/HiForm/HiUploadField.js +182 -0
  40. package/HiForm/HiUploadInput.js +459 -0
  41. package/HiForm/index.js +16 -0
  42. package/HiMap/HiMap.js +345 -0
  43. package/HiMap/HiMapExpand.js +210 -0
  44. package/HiMap/index.js +23 -0
  45. package/HiNotice/HiKPI.js +238 -0
  46. package/HiNotice/HiKPINotice.js +96 -0
  47. package/HiNotice/index.js +23 -0
  48. package/HiPdfReader/HiPdfReader.js +269 -0
  49. package/HiPdfReader/index.js +15 -0
  50. package/HiPin/HiPin.js +1 -1
  51. package/HiRadio/HiRadio.js +74 -0
  52. package/HiRadio/index.js +15 -0
  53. package/HiSelect/HiSelect.js +73 -84
  54. package/HiSelect/HiSuggestSelect.js +35 -4
  55. package/HiSelect/SelectInput.js +9 -1
  56. package/HiSelectNew/HiNestedSelectContent.js +5 -1
  57. package/HiSelectNew/HiSelect.js +260 -179
  58. package/HiSelectNew/HiSelectContent.js +0 -8
  59. package/HiSelectNew/HiSelectInput.js +8 -9
  60. package/HiSelectableList/HiSelectableList.js +39 -4
  61. package/HiSelectableList/HiSelectableListItem.js +81 -38
  62. package/HiTable/HiCellBuilder.js +25 -12
  63. package/HiTable/HiTableHeader.js +16 -17
  64. package/HiTable/constants.js +3 -1
  65. package/README.md +248 -98
  66. package/es/HiBreadcrumb/HiBreadcrumb.js +14 -4
  67. package/es/HiBreadcrumb/HiStep.js +4 -1
  68. package/es/HiBreadcrumb/HiStepContent.js +0 -1
  69. package/es/HiBreadcrumb/HiStepLabel.js +13 -4
  70. package/es/HiBreadcrumb/HiStepper.js +1 -1
  71. package/es/HiButton/HiButton.js +7 -0
  72. package/es/HiCell/CellIcon.js +5 -5
  73. package/es/HiCell/CellImage.js +13 -1
  74. package/es/HiCell/CellRate.js +6 -3
  75. package/es/HiCell/CellSentinel.js +7 -10
  76. package/es/HiCell/CellTextStyled.js +28 -1
  77. package/es/HiColoredLabel/HiColoredLabel.js +1 -1
  78. package/es/HiDatePicker/Caption.js +14 -10
  79. package/es/HiDatePicker/HiDatePicker.js +8 -3
  80. package/es/HiDatePicker/HiDateRangePicker.js +40 -28
  81. package/es/HiDatePicker/HiDateRangeSelector.js +69 -21
  82. package/es/HiDatePicker/ListPicker.js +1 -1
  83. package/es/HiDatePicker/NavBar.js +7 -1
  84. package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
  85. package/es/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +106 -0
  86. package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +5 -5
  87. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
  88. package/es/HiDatePicker/Overlays/Overlay.js +16 -9
  89. package/es/HiDatePicker/Overlays/Overlay.spec.js +1 -0
  90. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
  91. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
  92. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +4 -6
  93. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
  94. package/es/HiDatePicker/hiLocaleUtils.js +131 -0
  95. package/es/HiDatePicker/stylesheet.js +32 -7
  96. package/es/HiDotsStepper/HiDot.js +66 -0
  97. package/es/HiDotsStepper/HiDotsStepper.js +73 -0
  98. package/es/HiExpansionPanel/HiExpansionPanel.js +1 -1
  99. package/es/HiForm/HiAddressField.js +134 -0
  100. package/es/HiForm/HiFormControl.js +2 -0
  101. package/es/HiForm/HiInput.js +3 -3
  102. package/es/HiForm/HiSlider.js +302 -0
  103. package/es/HiForm/HiUpload.js +158 -0
  104. package/es/HiForm/HiUploadField.js +140 -0
  105. package/es/HiForm/HiUploadInput.js +411 -0
  106. package/es/HiForm/index.js +2 -0
  107. package/es/HiMap/HiMap.js +290 -0
  108. package/es/HiMap/HiMapExpand.js +162 -0
  109. package/es/HiMap/index.js +2 -0
  110. package/es/HiNotice/HiKPI.js +196 -0
  111. package/es/HiNotice/HiKPINotice.js +78 -0
  112. package/es/HiNotice/index.js +2 -0
  113. package/es/HiPdfReader/HiPdfReader.js +214 -0
  114. package/es/HiPdfReader/index.js +1 -0
  115. package/es/HiPin/HiPin.js +1 -1
  116. package/es/HiRadio/HiRadio.js +55 -0
  117. package/es/HiRadio/index.js +1 -0
  118. package/es/HiSelect/HiSelect.js +68 -78
  119. package/es/HiSelect/HiSuggestSelect.js +30 -4
  120. package/es/HiSelect/SelectInput.js +9 -1
  121. package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
  122. package/es/HiSelectNew/HiSelect.js +246 -162
  123. package/es/HiSelectNew/HiSelectContent.js +0 -7
  124. package/es/HiSelectNew/HiSelectInput.js +8 -9
  125. package/es/HiSelectableList/HiSelectableList.js +34 -6
  126. package/es/HiSelectableList/HiSelectableListItem.js +92 -40
  127. package/es/HiTable/HiCellBuilder.js +130 -123
  128. package/es/HiTable/HiTableHeader.js +14 -12
  129. package/es/HiTable/constants.js +1 -0
  130. package/es/index.js +9 -1
  131. package/es/utils/helpers.js +1 -1
  132. package/index.es.js +9 -1
  133. package/index.js +66 -2
  134. package/package.json +5 -2
  135. package/umd/hipay-material-ui.development.js +44450 -40930
  136. package/umd/hipay-material-ui.production.min.js +2 -2
  137. package/utils/helpers.js +1 -1
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { withStyles } from '@material-ui/core/styles';
4
+ import HiKPI from './HiKPI';
5
+
6
+ const styles = () => ({
7
+ container: {
8
+ minWidth: 230,
9
+ width: '100%',
10
+ display: 'flex',
11
+ flexWrap: 'wrap',
12
+ justifyContent: 'center'
13
+ }
14
+ });
15
+
16
+ const HiKPINotice = ({
17
+ classes,
18
+ kpis,
19
+ activeKpi,
20
+ minify,
21
+ onClickOnKPI
22
+ }) => {
23
+ return React.createElement("div", {
24
+ className: classes.container
25
+ }, Object.keys(kpis).map(key => {
26
+ const kpi = kpis[key];
27
+ return React.createElement(HiKPI, {
28
+ key: key,
29
+ id: key,
30
+ type: kpi.type,
31
+ color: kpi.color,
32
+ title: kpi.title,
33
+ body: kpi.body,
34
+ bodyMinify: kpi.bodyMinify,
35
+ subtitle: kpi.subtitle,
36
+ tooltip: kpi.tooltip,
37
+ onClick: () => onClickOnKPI(key),
38
+ active: activeKpi === key,
39
+ minify: minify,
40
+ disable: kpi.disable
41
+ });
42
+ }));
43
+ };
44
+
45
+ HiKPINotice.propTypes = process.env.NODE_ENV !== "production" ? {
46
+ /**
47
+ * Extension du style appliqué au composant
48
+ */
49
+ activeKpi: PropTypes.string,
50
+
51
+ /**
52
+ * Liste des KPIs
53
+ */
54
+ classes: PropTypes.object,
55
+
56
+ /**
57
+ * Fonction appelée au clic sur un KPI
58
+ */
59
+ kpis: PropTypes.object.isRequired,
60
+
61
+ /**
62
+ * Liste des KPIS actifs
63
+ */
64
+ minify: PropTypes.bool,
65
+
66
+ /**
67
+ * Minifie les KPIs si vrai
68
+ */
69
+ onClickOnKPI: PropTypes.func
70
+ } : {};
71
+ HiKPINotice.defaultProps = {
72
+ activeKpi: null,
73
+ minify: false
74
+ };
75
+ export default withStyles(styles, {
76
+ hiComponent: true,
77
+ name: 'HmuiHiKPINotice'
78
+ })(HiKPINotice);
@@ -0,0 +1,2 @@
1
+ export { default as HiKPI } from './HiKPI';
2
+ export { default as HiKPINotice } from './HiKPINotice';
@@ -0,0 +1,214 @@
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 HiButton from '../HiButton';
6
+ import HiIcon from '../HiIcon'; // import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
7
+ // import ChevronRightIcon from '@material-ui/icons/ChevronRight/';
8
+
9
+ import CircularProgress from '@material-ui/core/CircularProgress/';
10
+ import { withStyles } from '../styles';
11
+ export const styles = theme => ({
12
+ root: {
13
+ position: 'relative'
14
+ },
15
+ pageNumber: {
16
+ position: 'absolute',
17
+ bottom: 16,
18
+ left: -24,
19
+ backgroundColor: '#FFFFFF',
20
+ borderRadius: 4,
21
+ paddingTop: 7,
22
+ paddingBottom: 7,
23
+ paddingRight: 8,
24
+ paddingLeft: 8,
25
+ fontSize: 15,
26
+ fontFamily: theme.typography.fontFamily,
27
+ boxShadow: '1px 1px 5px rgba(0, 0, 0, .16)',
28
+ color: '#737373'
29
+ },
30
+ pagesNavigation: {
31
+ position: 'absolute',
32
+ top: 16,
33
+ right: -30,
34
+ backgroundColor: '#FFFFFF',
35
+ borderRadius: 3,
36
+ paddingTop: 4,
37
+ paddingBottom: 4,
38
+ paddingRight: 3,
39
+ paddingLeft: 3,
40
+ fontFamily: theme.typography.fontFamily,
41
+ boxShadow: '1px 1px 5px rgba(0, 0, 0, .16)',
42
+ color: '#737373',
43
+ '&>button:first-child': {
44
+ marginRight: 6
45
+ }
46
+ },
47
+ navigationButton: {
48
+ padding: 0,
49
+ minWidth: 0,
50
+ minHeight: 0
51
+ }
52
+ }); // Constantes utilisées pour le redimentionnement du PDF (format mobile par exemple)
53
+
54
+ const maxWindowWidth = 900;
55
+ const maxPdfWidth = 600;
56
+ let Document;
57
+ let Page;
58
+
59
+ var _ref = React.createElement(CircularProgress, null);
60
+
61
+ var _ref2 = React.createElement(HiIcon, {
62
+ icon: "chevron_left"
63
+ });
64
+
65
+ var _ref3 = React.createElement(HiIcon, {
66
+ icon: "chevron_right"
67
+ });
68
+
69
+ class HiPdfReader extends React.PureComponent {
70
+ constructor(...args) {
71
+ super(...args);
72
+ this.state = {
73
+ numPages: null,
74
+ pageNumber: 1,
75
+ error: false,
76
+ width: 600
77
+ };
78
+
79
+ this.handleLoadSuccess = ({
80
+ numPages
81
+ }) => {
82
+ this.setState({
83
+ numPages,
84
+ error: false
85
+ });
86
+ };
87
+
88
+ this.handleLoadError = () => {
89
+ this.setState({
90
+ error: true
91
+ });
92
+ };
93
+
94
+ this.handleClickNextPage = () => {
95
+ this.setState(prevState => ({
96
+ pageNumber: prevState.pageNumber + 1
97
+ }));
98
+ };
99
+
100
+ this.handleClickPreviousPage = () => {
101
+ this.setState(prevState => ({
102
+ pageNumber: prevState.pageNumber - 1
103
+ }));
104
+ };
105
+ }
106
+
107
+ componentDidMount() {
108
+ this.updateDimensions();
109
+ window.addEventListener('resize', this.updateDimensions.bind(this));
110
+ /* eslint-disable */
111
+
112
+ Document = require('react-pdf').Document;
113
+ Page = require('react-pdf').Page;
114
+ /* eslint-enable */
115
+
116
+ this.forceUpdate();
117
+ }
118
+
119
+ componentWillUnmount() {
120
+ window.removeEventListener('resize', this.updateDimensions.bind(this));
121
+ } // Fonction appelée une fois le pdf correctement chargé
122
+
123
+
124
+ // Calculate & Update state of new dimensions
125
+ updateDimensions() {
126
+ if (window.innerWidth < maxWindowWidth) {
127
+ const updateWidth = Math.round(window.innerWidth * 100 / maxWindowWidth / 100 * maxPdfWidth);
128
+ this.setState({
129
+ width: updateWidth
130
+ });
131
+ } else {
132
+ this.setState({
133
+ width: maxPdfWidth
134
+ });
135
+ }
136
+ } // Render
137
+
138
+
139
+ render() {
140
+ const {
141
+ pageNumber,
142
+ numPages,
143
+ error
144
+ } = this.state;
145
+
146
+ const _this$props = this.props,
147
+ {
148
+ classes,
149
+ file,
150
+ displayPagination,
151
+ displayNavigationButtons
152
+ } = _this$props,
153
+ props = _objectWithoutProperties(_this$props, ["classes", "file", "displayPagination", "displayNavigationButtons"]);
154
+
155
+ if (!Document || !Page) return null;
156
+ return React.createElement("div", {
157
+ className: classes.root
158
+ }, React.createElement(Document, _extends({
159
+ className: classes.style,
160
+ file: file,
161
+ onLoadSuccess: this.handleLoadSuccess,
162
+ onLoadError: this.handleLoadError,
163
+ loading: _ref
164
+ }, props), React.createElement(Page, {
165
+ pageNumber: pageNumber,
166
+ renderAnnotations: false,
167
+ renderTextLayer: false,
168
+ width: this.state.width
169
+ })), !error && numPages > 1 && displayPagination && React.createElement("span", {
170
+ className: classes.pageNumber
171
+ }, "Page ", pageNumber, " sur ", numPages), !error && numPages > 1 && displayNavigationButtons && React.createElement("span", {
172
+ className: classes.pagesNavigation
173
+ }, React.createElement(HiButton, {
174
+ onClick: this.handleClickPreviousPage,
175
+ disabled: pageNumber === 1,
176
+ className: classes.navigationButton
177
+ }, _ref2), React.createElement(HiButton, {
178
+ onClick: this.handleClickNextPage,
179
+ disabled: pageNumber === numPages,
180
+ className: classes.navigationButton
181
+ }, _ref3)));
182
+ }
183
+
184
+ }
185
+
186
+ HiPdfReader.defaultProps = {
187
+ displayPagination: true,
188
+ displayNavigationButtons: true
189
+ };
190
+ HiPdfReader.propTypes = process.env.NODE_ENV !== "production" ? {
191
+ /**
192
+ * Surcharge les classes du composant
193
+ */
194
+ classes: PropTypes.object,
195
+
196
+ /**
197
+ * On affiche les boutons de navigation entre les pages si le PDF contient plusieurs pages
198
+ */
199
+ displayNavigationButtons: PropTypes.bool,
200
+
201
+ /**
202
+ * On affiche la pagination si le PDF contient plusieurs pages
203
+ */
204
+ displayPagination: PropTypes.bool,
205
+
206
+ /**
207
+ * Chemin vers le fichier PDF
208
+ */
209
+ file: PropTypes.string.isRequired
210
+ } : {};
211
+ export default withStyles(styles, {
212
+ name: 'HmuiHiPdfReader',
213
+ index: 51
214
+ })(HiPdfReader);
@@ -0,0 +1 @@
1
+ export { default } from './HiPdfReader';
package/es/HiPin/HiPin.js CHANGED
@@ -6,7 +6,7 @@ import { withStyles } from '../styles';
6
6
  export const styles = theme => ({
7
7
  root: {
8
8
  display: 'inline-block',
9
- padding: '0 9px',
9
+ padding: '1px 9px',
10
10
  height: 16,
11
11
  lineHeight: '16px',
12
12
  minWidth: 25,
@@ -0,0 +1,55 @@
1
+ // @inheritedComponent Radio
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { withStyles } from '../styles';
5
+ import Radio from '@material-ui/core/Radio';
6
+ export const styles = theme => ({
7
+ checked: {
8
+ color: theme.palette.neutral.main
9
+ },
10
+ disabled: {
11
+ color: theme.palette.action.disabled
12
+ }
13
+ });
14
+
15
+ const HiRadio = ({
16
+ checked,
17
+ classes,
18
+ className,
19
+ color,
20
+ disabled,
21
+ label,
22
+ onChange,
23
+ value
24
+ }) => {
25
+ const hcolor = ['positive', 'negative', 'middle', 'neutral', 'inherit'].includes(color) ? 'default' : color;
26
+ return React.createElement(Radio, {
27
+ className: className,
28
+ classes: {
29
+ checked: classes.checked,
30
+ disabled: classes.disabled
31
+ },
32
+ checked: checked,
33
+ color: hcolor,
34
+ label: label,
35
+ onChange: onChange,
36
+ disabled: disabled,
37
+ value: value
38
+ });
39
+ };
40
+
41
+ HiRadio.propTypes = process.env.NODE_ENV !== "production" ? {
42
+ checked: PropTypes.bool,
43
+ classes: PropTypes.object,
44
+ className: PropTypes.string,
45
+ color: PropTypes.oneOf(['inherit', 'primary', 'secondary', 'positive', 'negative', 'middle', 'neutral']),
46
+ disabled: PropTypes.bool,
47
+ label: PropTypes.string,
48
+ onChange: PropTypes.func,
49
+ value: PropTypes.string
50
+ } : {};
51
+ HiRadio.defaultProps = {};
52
+ export default withStyles(styles, {
53
+ hiComponent: true,
54
+ name: 'HmuiHiRadio'
55
+ })(HiRadio);
@@ -0,0 +1 @@
1
+ export { default } from './HiRadio';
@@ -70,28 +70,6 @@ class HiSelect extends React.PureComponent {
70
70
  constructor(_props) {
71
71
  super(_props);
72
72
 
73
- this.handleClick = () => {
74
- if (this.state.open) {
75
- this.handleClose();
76
- } else {
77
- this.setState({
78
- open: true
79
- });
80
- const options = this.props.options.slice();
81
- this.handleSuggestions(options);
82
-
83
- if (this.props.onClick) {
84
- this.props.onClick();
85
- } // Gestion du focus
86
-
87
-
88
- if (!this.props.searchable) {
89
- // sinon focus sur le dernier élément selectionné
90
- this.focusOnSelectedItem();
91
- }
92
- }
93
- };
94
-
95
73
  this.buildHierarchyTrees = props => {
96
74
  // Construct two associative arrays
97
75
  // hierarchy[parentId] => children
@@ -153,6 +131,61 @@ class HiSelect extends React.PureComponent {
153
131
  }, 1);
154
132
  };
155
133
 
134
+ this.handleBlur = () => {
135
+ this.setState({
136
+ focused: false
137
+ });
138
+ };
139
+
140
+ this.handleClick = () => {
141
+ if (this.state.open) {
142
+ this.handleClose();
143
+ } else {
144
+ this.setState({
145
+ open: true
146
+ });
147
+ const options = this.props.options.slice();
148
+ this.handleSuggestions(options);
149
+
150
+ if (this.props.onClick) {
151
+ this.props.onClick();
152
+ } // Gestion du focus
153
+
154
+
155
+ if (!this.props.searchable) {
156
+ // sinon focus sur le dernier élément selectionné
157
+ this.focusOnSelectedItem();
158
+ }
159
+ }
160
+ };
161
+
162
+ this.handleClickAway = event => {
163
+ // Au clic sur le bouton, on laisse le handleClick fermer le select
164
+ if (!this.selectInputElement.contains(event.target)) {
165
+ this.handleClose(event);
166
+ }
167
+ };
168
+
169
+ this.handleClose = () => {
170
+ if (this.props.onClose) {
171
+ this.props.onClose();
172
+ }
173
+
174
+ if (this.selectInputElement) {
175
+ this.selectInputElement.focus();
176
+ }
177
+
178
+ this.setState({
179
+ open: false
180
+ });
181
+ };
182
+
183
+ this.handleFocus = () => {
184
+ this.setState({
185
+ focused: true
186
+ });
187
+ };
188
+
156
189
  this.handleKeyDown = event => {
157
190
  let nextItem;
158
191
 
@@ -186,36 +219,24 @@ class HiSelect extends React.PureComponent {
186
219
  }
187
220
  };
188
221
 
189
- this.handleFocus = () => {
190
- this.setState({
191
- focused: true
192
- });
193
- };
194
-
195
- this.handleBlur = () => {
196
- this.setState({
197
- focused: false
198
- });
222
+ this.handleRequestDelete = event => {
223
+ event.stopPropagation();
224
+ this.props.onChange(this.props.name, []);
199
225
  };
200
226
 
201
- this.handleClose = () => {
202
- if (this.props.onClose) {
203
- this.props.onClose();
204
- }
205
-
206
- if (this.selectInputElement) {
207
- this.selectInputElement.focus();
227
+ this.handleReset = event => {
228
+ if (this.props.onReset) {
229
+ event.stopPropagation();
230
+ this.props.onReset(event);
208
231
  }
209
-
210
- this.setState({
211
- open: false
212
- });
213
232
  };
214
233
 
215
- this.handleClickAway = event => {
216
- // Au clic sur le bouton, on laisse le handleClick fermer le select
217
- if (!this.selectInputElement.contains(event.target)) {
218
- this.handleClose(event);
234
+ this.handleScroll = event => {
235
+ if (!this.props.loadingMoreResults && this.props.hasMore && event.target.scrollHeight - event.target.clientHeight - event.target.scrollTop < 15) {
236
+ this.props.loadMoreResults(this.state.resultsPageNumber + 1);
237
+ this.setState(prevState => ({
238
+ resultsPageNumber: prevState.resultsPageNumber + 1
239
+ }));
219
240
  }
220
241
  };
221
242
 
@@ -386,20 +407,6 @@ class HiSelect extends React.PureComponent {
386
407
  });
387
408
  };
388
409
 
389
- this.handleRequestDelete = evt => {
390
- evt.stopPropagation();
391
- this.props.onChange(this.props.name, []);
392
- };
393
-
394
- this.handleScroll = event => {
395
- if (!this.props.loadingMoreResults && this.props.hasMore && event.target.scrollHeight - event.target.clientHeight - event.target.scrollTop < 15) {
396
- this.props.loadMoreResults(this.state.resultsPageNumber + 1);
397
- this.setState(prevState => ({
398
- resultsPageNumber: prevState.resultsPageNumber + 1
399
- }));
400
- }
401
- };
402
-
403
410
  this.state = {
404
411
  open: false,
405
412
  focused: false,
@@ -455,16 +462,6 @@ class HiSelect extends React.PureComponent {
455
462
  } else if (!_props.dynamic) {
456
463
  this.state.dynamic = true;
457
464
  }
458
-
459
- this.handleSelect = this.handleSelect.bind(this);
460
- this.handleClick = this.handleClick.bind(this);
461
- this.handleClose = this.handleClose.bind(this);
462
- this.handleClickAway = this.handleClickAway.bind(this);
463
- this.handleRequestDelete = this.handleRequestDelete.bind(this);
464
- this.handleSuggestions = this.handleSuggestions.bind(this);
465
- this.handleFocus = this.handleFocus.bind(this);
466
- this.handleBlur = this.handleBlur.bind(this);
467
- this.handleScroll = this.handleScroll.bind(this);
468
465
  }
469
466
 
470
467
  componentWillReceiveProps(nextProps) {
@@ -490,13 +487,6 @@ class HiSelect extends React.PureComponent {
490
487
  }
491
488
  }
492
489
 
493
- handleReset(event) {
494
- if (this.props.onReset) {
495
- event.stopPropagation();
496
- this.props.onReset(event);
497
- }
498
- }
499
-
500
490
  render() {
501
491
  const _this$props = this.props,
502
492
  {
@@ -12,6 +12,7 @@ import HiInput from '../HiForm/HiInput';
12
12
  import { withStyles } from '../styles';
13
13
  import Popper from '@material-ui/core/Popper';
14
14
  import { getNextItemSelectable } from '../utils/helpers';
15
+ import keycode from 'keycode';
15
16
  export const styles = theme => ({
16
17
  root: {
17
18
  backgroundColor: theme.palette.background2,
@@ -64,13 +65,20 @@ class HiSuggestSelect extends React.PureComponent {
64
65
 
65
66
  this.handleKeyDown = event => {
66
67
  let nextItem;
68
+ const key = keycode(event);
67
69
 
68
- if (event.key === 'ArrowDown') {
70
+ if (key === 'down') {
71
+ event.preventDefault();
69
72
  nextItem = getNextItemSelectable(document.activeElement, 'down');
70
- } else if (event.key === 'ArrowUp') {
73
+ } else if (key === 'up') {
74
+ event.preventDefault();
71
75
  nextItem = getNextItemSelectable(document.activeElement, 'up');
72
- } else if (event.key === 'Tab') {
76
+ } else if (key === 'tab') {
73
77
  document.body.style.overflow = 'auto';
78
+ } else if (key === 'escape' || 'enter') {
79
+ event.preventDefault();
80
+ const item = this.props.options.find(elem => String(elem.id) === event.target.id);
81
+ this.handleSelect(null, item);
74
82
  }
75
83
 
76
84
  if (nextItem) {
@@ -117,10 +125,14 @@ class HiSuggestSelect extends React.PureComponent {
117
125
  }
118
126
  }
119
127
 
120
- handleFocus() {
128
+ handleFocus(event) {
121
129
  this.setState({
122
130
  focused: true
123
131
  });
132
+
133
+ if (this.props.onFocusInput) {
134
+ this.props.onFocusInput(event);
135
+ }
124
136
  }
125
137
 
126
138
  handleBlur(event) {
@@ -132,6 +144,10 @@ class HiSuggestSelect extends React.PureComponent {
132
144
  focused: false
133
145
  });
134
146
  }
147
+
148
+ if (this.props.onBlurInput) {
149
+ this.props.onBlurInput(event);
150
+ }
135
151
  }
136
152
 
137
153
  render() {
@@ -253,6 +269,16 @@ HiSuggestSelect.propTypes = process.env.NODE_ENV !== "production" ? {
253
269
  */
254
270
  loading: PropTypes.bool,
255
271
 
272
+ /**
273
+ * Fonction de callback appelée lorsqu'on blur le champ de recherche
274
+ */
275
+ onBlurInput: PropTypes.func,
276
+
277
+ /**
278
+ * Fonction de callback appelée lorsqu'on focus le champs de recherche
279
+ */
280
+ onFocusInput: PropTypes.func,
281
+
256
282
  /**
257
283
  * Fonction de callback appelée lorsqu'on écrit dans le champ
258
284
  */
@@ -13,7 +13,10 @@ export const styles = theme => ({
13
13
  maxWidth: 500,
14
14
  display: 'flex',
15
15
  justifyContent: 'center',
16
- padding: 8,
16
+ paddingTop: 7,
17
+ paddingBottom: 9,
18
+ paddingRight: 8,
19
+ paddingLeft: 8,
17
20
  cursor: 'pointer'
18
21
  },
19
22
  underline: {
@@ -300,6 +303,11 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
300
303
  */
301
304
  refElement: PropTypes.func,
302
305
 
306
+ /**
307
+ * Theme object
308
+ */
309
+ theme: PropTypes.object,
310
+
303
311
  /**
304
312
  * Valeur à afficher (déjà formattée)
305
313
  */
@@ -175,7 +175,6 @@ class HiNestedSelectContent extends React.PureComponent {
175
175
 
176
176
  this.buildSelectProps = (options, value = [], search = '', loading = false) => {
177
177
  const {
178
- classes,
179
178
  disabledParent,
180
179
  hasAll,
181
180
  iconAll,
@@ -291,6 +290,11 @@ HiNestedSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
291
290
  */
292
291
  hasAll: PropTypes.bool,
293
292
 
293
+ /**
294
+ * Propriétés du composant HiSelectableList
295
+ */
296
+ hiSelectableListProps: PropTypes.object,
297
+
294
298
  /**
295
299
  * id du select
296
300
  */