@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
@@ -0,0 +1,411 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import classNames from 'classnames';
|
5
|
+
import withStyles from '../styles/withStyles';
|
6
|
+
import HiIconButton from '../HiIconButton';
|
7
|
+
import RemoveRedEye from '@material-ui/icons/RemoveRedEye';
|
8
|
+
import Delete from '@material-ui/icons/Delete';
|
9
|
+
export const styles = theme => ({
|
10
|
+
root: _objectSpread({
|
11
|
+
position: 'relative'
|
12
|
+
}, theme.typography.body1, {
|
13
|
+
borderBottom: `1px solid ${theme.palette.input.bottomLine}`,
|
14
|
+
paddingLeft: 8,
|
15
|
+
backgroundColor: theme.palette.local.background2,
|
16
|
+
height: 40,
|
17
|
+
display: 'inline-flex',
|
18
|
+
justifyContent: 'flex-start',
|
19
|
+
'&$focused, &$dragOver': {
|
20
|
+
backgroundColor: theme.palette.global.background1
|
21
|
+
},
|
22
|
+
width: '100%',
|
23
|
+
// Ajout d'1px pour ne pas avoir de décalage en mode error avec le border top
|
24
|
+
'&:not($error)': {
|
25
|
+
marginTop: 1
|
26
|
+
}
|
27
|
+
}),
|
28
|
+
underline: {
|
29
|
+
'&:before': {
|
30
|
+
left: 0,
|
31
|
+
bottom: 0,
|
32
|
+
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
33
|
+
content: '""',
|
34
|
+
height: 1,
|
35
|
+
position: 'absolute',
|
36
|
+
right: 0,
|
37
|
+
transition: theme.transitions.create('background-color', {
|
38
|
+
duration: theme.transitions.duration.shorter,
|
39
|
+
easing: theme.transitions.easing.ease
|
40
|
+
}),
|
41
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
42
|
+
|
43
|
+
},
|
44
|
+
'&:hover:not($disabled):before': {
|
45
|
+
backgroundColor: theme.palette.input.bottomLine,
|
46
|
+
height: 2
|
47
|
+
},
|
48
|
+
'&$disabled:before': {
|
49
|
+
background: 'transparent',
|
50
|
+
backgroundImage: `linear-gradient(to right, ${theme.palette.input.bottomLine} 33%, transparent 0%)`,
|
51
|
+
backgroundPosition: 'left top',
|
52
|
+
backgroundRepeat: 'repeat-x',
|
53
|
+
backgroundSize: '5px 1px'
|
54
|
+
}
|
55
|
+
},
|
56
|
+
inkbar: {
|
57
|
+
'&:not($disabled)': {
|
58
|
+
'&:not($error):after': {
|
59
|
+
backgroundColor: theme.palette.primary.main,
|
60
|
+
left: 0,
|
61
|
+
bottom: 0,
|
62
|
+
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
63
|
+
content: '""',
|
64
|
+
height: 1,
|
65
|
+
position: 'absolute',
|
66
|
+
right: 0,
|
67
|
+
transform: 'scaleX(0)',
|
68
|
+
transition: theme.transitions.create('transform', {
|
69
|
+
duration: theme.transitions.duration.shorter,
|
70
|
+
easing: theme.transitions.easing.easeOut
|
71
|
+
}),
|
72
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
73
|
+
|
74
|
+
},
|
75
|
+
'&:hover:after': {
|
76
|
+
transform: 'scaleX(1)'
|
77
|
+
},
|
78
|
+
'&$dragOver:after': {
|
79
|
+
transform: 'scaleX(1)'
|
80
|
+
},
|
81
|
+
'&$focused:after': {
|
82
|
+
transform: 'scaleX(1)'
|
83
|
+
},
|
84
|
+
'&$error': {
|
85
|
+
borderBottom: `1px solid ${theme.palette.negative.normal}`
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
disabled: {
|
90
|
+
color: `${theme.palette.action.disabled}`,
|
91
|
+
'&:before': {
|
92
|
+
display: 'none'
|
93
|
+
}
|
94
|
+
},
|
95
|
+
focused: {
|
96
|
+
backgroundColor: theme.palette.background3
|
97
|
+
},
|
98
|
+
error: {},
|
99
|
+
label: _objectSpread({}, theme.typography.body1, {
|
100
|
+
fontWeight: theme.typography.fontWeightRegular,
|
101
|
+
caretColor: theme.palette.primary.main,
|
102
|
+
alignItems: 'center',
|
103
|
+
whiteSpace: 'nowrap',
|
104
|
+
overflow: 'hidden',
|
105
|
+
textOverflow: 'ellipsis',
|
106
|
+
padding: `${theme.spacing.unit - 2}px 0 ${theme.spacing.unit - 1}px`,
|
107
|
+
height: 39,
|
108
|
+
display: 'inline-flex',
|
109
|
+
width: '100%',
|
110
|
+
'&$empty': {
|
111
|
+
opacity: 0.42
|
112
|
+
}
|
113
|
+
}),
|
114
|
+
empty: {},
|
115
|
+
dragOver: {},
|
116
|
+
droppable: {},
|
117
|
+
endAdornment: {
|
118
|
+
display: 'flex',
|
119
|
+
alignItems: 'center'
|
120
|
+
},
|
121
|
+
icon: {
|
122
|
+
display: 'inline-flex',
|
123
|
+
alignItems: 'center',
|
124
|
+
right: 0,
|
125
|
+
padding: '8px',
|
126
|
+
color: `${theme.palette.text.icon}`,
|
127
|
+
fontSize: 10,
|
128
|
+
transition: theme.transitions.create(['opacity', 'transform'], {
|
129
|
+
duration: theme.transitions.duration.shorter
|
130
|
+
}),
|
131
|
+
'&:hover': {
|
132
|
+
color: 'inherit',
|
133
|
+
backgroundColor: theme.palette.local.background2
|
134
|
+
}
|
135
|
+
}
|
136
|
+
});
|
137
|
+
|
138
|
+
var _ref = React.createElement(RemoveRedEye, null);
|
139
|
+
|
140
|
+
var _ref2 = React.createElement(Delete, null);
|
141
|
+
|
142
|
+
class HiUploadInput extends React.Component {
|
143
|
+
constructor(props) {
|
144
|
+
super(props);
|
145
|
+
|
146
|
+
this.handleDrop = event => {
|
147
|
+
if (event.target === this.uploadFieldRef) {
|
148
|
+
event.preventDefault();
|
149
|
+
event.stopPropagation();
|
150
|
+
|
151
|
+
if (this.state.droppable) {
|
152
|
+
const param = this.handleFile(event.dataTransfer.files);
|
153
|
+
this.setState({
|
154
|
+
dragOver: false
|
155
|
+
});
|
156
|
+
this.props.onChange(param, this.props.index);
|
157
|
+
} else {
|
158
|
+
this.setState({
|
159
|
+
errorMessage: this.props.translations.errorDropMultiple,
|
160
|
+
dragOver: false
|
161
|
+
});
|
162
|
+
}
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
this.handleDragEnter = event => {
|
167
|
+
event.preventDefault();
|
168
|
+
event.stopPropagation();
|
169
|
+
|
170
|
+
if (event.target === this.uploadFieldRef) {
|
171
|
+
if (event.dataTransfer.items.length !== 1) {
|
172
|
+
event.dataTransfer.dropEffect = 'none';
|
173
|
+
this.props.onChange({
|
174
|
+
errorMessage: this.props.translations.errorDragEnter,
|
175
|
+
value: null
|
176
|
+
}, this.props.index);
|
177
|
+
this.setState({
|
178
|
+
dragOver: true
|
179
|
+
});
|
180
|
+
} else {
|
181
|
+
this.setState({
|
182
|
+
droppable: true,
|
183
|
+
dragOver: true
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
};
|
188
|
+
|
189
|
+
this.handleDragLeave = event => {
|
190
|
+
event.preventDefault();
|
191
|
+
event.stopPropagation();
|
192
|
+
|
193
|
+
if (event.target === this.uploadFieldRef && event.relatedTarget.parentElement !== this.uploadFieldRef) {
|
194
|
+
this.props.onChange({
|
195
|
+
errorMessage: '',
|
196
|
+
value: null
|
197
|
+
}, this.props.index);
|
198
|
+
this.setState({
|
199
|
+
droppable: false,
|
200
|
+
dragOver: false
|
201
|
+
});
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
this.handleChange = event => {
|
206
|
+
const param = this.handleFile(event.target.files);
|
207
|
+
this.props.onChange(param, this.props.index);
|
208
|
+
};
|
209
|
+
|
210
|
+
this.handleDeleteFile = () => {
|
211
|
+
this.props.onDeleteFile(this.props.index);
|
212
|
+
};
|
213
|
+
|
214
|
+
this.handleEmptyField = event => {
|
215
|
+
event.target.value = '';
|
216
|
+
};
|
217
|
+
|
218
|
+
this.handleSeeFile = () => {
|
219
|
+
this.props.onSeeFile(this.props.value);
|
220
|
+
};
|
221
|
+
|
222
|
+
this.handleFile = files => {
|
223
|
+
let error = false;
|
224
|
+
let errorMessage = '';
|
225
|
+
let file = null;
|
226
|
+
|
227
|
+
if (files.length === 1) {
|
228
|
+
file = files[0];
|
229
|
+
errorMessage = '';
|
230
|
+
|
231
|
+
if (file.size > this.props.maxSize) {
|
232
|
+
errorMessage += this.props.translations.errorSize.replace('maxSize', this.props.maxSize / 1000000);
|
233
|
+
error = true;
|
234
|
+
}
|
235
|
+
|
236
|
+
if (this.props.acceptedTypes.length !== 0 && this.props.acceptedTypes.indexOf(file.type) === -1) {
|
237
|
+
errorMessage += this.props.translations.errorType;
|
238
|
+
error = true;
|
239
|
+
}
|
240
|
+
} else {
|
241
|
+
errorMessage = this.props.translations.errorDropMultiple;
|
242
|
+
}
|
243
|
+
|
244
|
+
return {
|
245
|
+
errorMessage,
|
246
|
+
error,
|
247
|
+
value: file
|
248
|
+
};
|
249
|
+
};
|
250
|
+
|
251
|
+
this.uploadFieldRef = void 0;
|
252
|
+
this.state = {
|
253
|
+
errorMessage: '',
|
254
|
+
dragOver: false,
|
255
|
+
droppable: false
|
256
|
+
};
|
257
|
+
} // When component mounts, we add eventListeners to handle the file drag and drop
|
258
|
+
|
259
|
+
|
260
|
+
componentDidMount() {
|
261
|
+
this.uploadFieldRef.addEventListener('dragenter', this.handleDragEnter, false);
|
262
|
+
this.uploadFieldRef.addEventListener('dragleave', this.handleDragLeave, false);
|
263
|
+
this.uploadFieldRef.addEventListener('dragover', event => {
|
264
|
+
event.preventDefault();
|
265
|
+
}, false);
|
266
|
+
this.uploadFieldRef.addEventListener('drop', this.handleDrop, false);
|
267
|
+
}
|
268
|
+
|
269
|
+
componentWillUnmount() {
|
270
|
+
this.uploadFieldRef.removeEventListener('dragenter', this.handleDragEnter, false);
|
271
|
+
this.uploadFieldRef.removeEventListener('dragleave', this.handleDragLeave, false);
|
272
|
+
this.uploadFieldRef.removeEventListener('dragover', event => {
|
273
|
+
event.preventDefault();
|
274
|
+
}, false);
|
275
|
+
this.uploadFieldRef.removeEventListener('drop', this.handleDrop, false);
|
276
|
+
} // Action when files are dropped on the field
|
277
|
+
|
278
|
+
|
279
|
+
render() {
|
280
|
+
const {
|
281
|
+
placeholder,
|
282
|
+
classes,
|
283
|
+
disabled,
|
284
|
+
focused,
|
285
|
+
value,
|
286
|
+
error
|
287
|
+
} = this.props;
|
288
|
+
const {
|
289
|
+
dragOver,
|
290
|
+
errorMessage,
|
291
|
+
droppable
|
292
|
+
} = this.state; // On utilise classNames pour variabiliser les styles et merger les classes appliquées
|
293
|
+
|
294
|
+
const rootClass = classNames(classes.root, classes.inkbar, classes.underline, {
|
295
|
+
[classes.disabled]: disabled,
|
296
|
+
[classes.focused]: focused,
|
297
|
+
[classes.error]: error && !focused,
|
298
|
+
[classes.dragOver]: dragOver,
|
299
|
+
[classes.droppable]: droppable
|
300
|
+
});
|
301
|
+
return React.createElement("div", {
|
302
|
+
className: rootClass
|
303
|
+
}, React.createElement("label", {
|
304
|
+
className: classNames(classes.label, {
|
305
|
+
[classes.empty]: value === null
|
306
|
+
}),
|
307
|
+
ref: label => {
|
308
|
+
this.uploadFieldRef = label;
|
309
|
+
}
|
310
|
+
}, value ? value.name : error && errorMessage || placeholder, React.createElement("input", {
|
311
|
+
type: 'file',
|
312
|
+
onClick: this.handleEmptyField,
|
313
|
+
hidden: true,
|
314
|
+
onChange: this.handleChange
|
315
|
+
})), value === null || React.createElement("div", {
|
316
|
+
className: classes.endAdornment
|
317
|
+
}, React.createElement(HiIconButton, {
|
318
|
+
className: classes.icon,
|
319
|
+
onClick: this.handleSeeFile
|
320
|
+
}, _ref), React.createElement(HiIconButton, {
|
321
|
+
className: classes.icon,
|
322
|
+
onClick: this.handleDeleteFile
|
323
|
+
}, _ref2)));
|
324
|
+
}
|
325
|
+
|
326
|
+
}
|
327
|
+
|
328
|
+
HiUploadInput.defaultProps = {
|
329
|
+
placeholder: 'Choose a file',
|
330
|
+
disabled: false,
|
331
|
+
focused: false,
|
332
|
+
acceptedTypes: [],
|
333
|
+
maxSize: 10000000,
|
334
|
+
value: null,
|
335
|
+
translations: {
|
336
|
+
errorSize: "Votre fichier est trop lourd. Nous acceptons jusqu'à maxSizeMo",
|
337
|
+
errorDropMultiple: 'Veuillez insérer un et un seul fichier',
|
338
|
+
errorType: "Ce type de fichier n'est pas accepté",
|
339
|
+
errorDragEnter: 'Contenu non correct'
|
340
|
+
}
|
341
|
+
};
|
342
|
+
HiUploadInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
343
|
+
/**
|
344
|
+
* Defines what kind of file types the input accepts. If empty, no restrictions about the file type.
|
345
|
+
*/
|
346
|
+
acceptedTypes: PropTypes.array,
|
347
|
+
|
348
|
+
/**
|
349
|
+
* Useful to extend the style applied to components.
|
350
|
+
*/
|
351
|
+
classes: PropTypes.object,
|
352
|
+
|
353
|
+
/**
|
354
|
+
* Is the field disabled.
|
355
|
+
*/
|
356
|
+
disabled: PropTypes.bool,
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Is there an error with the file selected.
|
360
|
+
*/
|
361
|
+
error: PropTypes.bool,
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Is the field focused.
|
365
|
+
*/
|
366
|
+
focused: PropTypes.bool,
|
367
|
+
|
368
|
+
/**
|
369
|
+
* The index of the input.
|
370
|
+
*/
|
371
|
+
index: PropTypes.number,
|
372
|
+
|
373
|
+
/**
|
374
|
+
* Defines what size the file must not exceed (in bytes).
|
375
|
+
*/
|
376
|
+
maxSize: PropTypes.number,
|
377
|
+
|
378
|
+
/**
|
379
|
+
* The change handler.
|
380
|
+
*/
|
381
|
+
onChange: PropTypes.func,
|
382
|
+
|
383
|
+
/**
|
384
|
+
* The handler to clear the field.
|
385
|
+
*/
|
386
|
+
onDeleteFile: PropTypes.func,
|
387
|
+
|
388
|
+
/**
|
389
|
+
* The handler to see the file.
|
390
|
+
*/
|
391
|
+
onSeeFile: PropTypes.func,
|
392
|
+
|
393
|
+
/**
|
394
|
+
* The placeholder for the field.
|
395
|
+
*/
|
396
|
+
placeholder: PropTypes.string,
|
397
|
+
|
398
|
+
/**
|
399
|
+
* The translations of the error messages.
|
400
|
+
*/
|
401
|
+
translations: PropTypes.object,
|
402
|
+
|
403
|
+
/**
|
404
|
+
* The file value for the field.
|
405
|
+
*/
|
406
|
+
value: PropTypes.object
|
407
|
+
} : {};
|
408
|
+
export default withStyles(styles, {
|
409
|
+
hiComponent: true,
|
410
|
+
name: 'HmuiHiUploadInput'
|
411
|
+
})(HiUploadInput);
|
package/es/HiForm/index.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
export { default as HiAddressField } from './HiAddressField';
|
1
2
|
export { default as HiEmailField } from './HiEmailField';
|
2
3
|
export { default as HiFormControl } from './HiFormControl';
|
3
4
|
export { default as HiFormLabel } from './HiFormLabel';
|
4
5
|
export { default as HiInput } from './HiInput';
|
5
6
|
export { default as HiPasswordField } from './HiPasswordField';
|
6
7
|
export { default as HiSearchField } from './HiSearchField';
|
8
|
+
export { default as HiSlider } from './HiSlider';
|
7
9
|
export { default as HiTextField } from './HiTextField';
|
@@ -0,0 +1,290 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { withStyles } from '../styles';
|
4
|
+
import HiButton from '../HiButton';
|
5
|
+
import HiIcon from '../HiIcon';
|
6
|
+
import HiLoader from '../HiLoader';
|
7
|
+
const apiUrl = 'https://nominatim.openstreetmap.org/search?q='; // The original CSS can be found here : https://unpkg.com/leaflet@1.3.1/dist/leaflet.css
|
8
|
+
|
9
|
+
export const styles = theme => ({
|
10
|
+
map: {
|
11
|
+
height: '100%',
|
12
|
+
overflow: 'hidden',
|
13
|
+
// eslint-disable-next-line max-len
|
14
|
+
'& .leaflet-pane, & .leaflet-tile, & .leaflet-marker-icon, & .leaflet-marker-shadow, & .leaflet-tile-container, & .leaflet-pane > svg, & .leaflet-pane > canvas, & .leaflet-zoom-box, & .leaflet-image-layer, & .leaflet-layer': {
|
15
|
+
position: 'absolute',
|
16
|
+
left: 0,
|
17
|
+
top: 0
|
18
|
+
},
|
19
|
+
'& .leaflet-container': {
|
20
|
+
overflow: 'hidden',
|
21
|
+
height: '100%'
|
22
|
+
},
|
23
|
+
'& .leaflet-tile, & .leaflet-marker-icon, & .leaflet-marker-shadow': {
|
24
|
+
'-webkit-user-select': 'none',
|
25
|
+
'-moz-user-select': 'none',
|
26
|
+
userSelect: 'none',
|
27
|
+
'-webkit-user-drag': 'none'
|
28
|
+
},
|
29
|
+
'& .leaflet-control': {
|
30
|
+
display: 'none'
|
31
|
+
},
|
32
|
+
'& .map_marker': {
|
33
|
+
fill: theme.palette.primary.light
|
34
|
+
}
|
35
|
+
},
|
36
|
+
controlButtons: {
|
37
|
+
position: 'absolute',
|
38
|
+
bottom: 16,
|
39
|
+
right: 16
|
40
|
+
},
|
41
|
+
centerIcon: {
|
42
|
+
fontSize: 14
|
43
|
+
},
|
44
|
+
centerButtonContainer: {
|
45
|
+
backgroundColor: theme.palette.global.background1,
|
46
|
+
borderRadius: 3,
|
47
|
+
padding: 3,
|
48
|
+
fontFamily: theme.typography.fontFamily,
|
49
|
+
boxShadow: '1px 1px 5px rgba(0, 0, 0, .16)',
|
50
|
+
color: theme.palette.neutral.normal,
|
51
|
+
'&>button:first-child': {
|
52
|
+
borderBottom: `1px solid ${theme.palette.neutral.normal}`
|
53
|
+
}
|
54
|
+
},
|
55
|
+
centerButton: {
|
56
|
+
color: theme.palette.neutral.normal,
|
57
|
+
padding: '1px !important',
|
58
|
+
height: 26,
|
59
|
+
minHeight: 26,
|
60
|
+
width: 26,
|
61
|
+
minWidth: 26
|
62
|
+
},
|
63
|
+
zoomButtons: {
|
64
|
+
backgroundColor: theme.palette.global.background1,
|
65
|
+
borderRadius: 3,
|
66
|
+
padding: 3,
|
67
|
+
fontFamily: theme.typography.fontFamily,
|
68
|
+
boxShadow: '1px 1px 5px rgba(0, 0, 0, .16)',
|
69
|
+
color: theme.palette.neutral.normal,
|
70
|
+
'&>button:first-child': {
|
71
|
+
borderBottom: `1px solid ${theme.palette.neutral.normal}`
|
72
|
+
}
|
73
|
+
},
|
74
|
+
zoomButton: {
|
75
|
+
paddingTop: '0px !important',
|
76
|
+
paddingBottom: 0,
|
77
|
+
paddingRight: 6,
|
78
|
+
paddingLeft: 6,
|
79
|
+
minWidth: 0,
|
80
|
+
minHeight: 0,
|
81
|
+
borderRadius: 0,
|
82
|
+
display: 'block',
|
83
|
+
fontSize: 24,
|
84
|
+
fontWeight: 'bold',
|
85
|
+
lineHeight: '26px',
|
86
|
+
'&>span': {
|
87
|
+
width: 14
|
88
|
+
}
|
89
|
+
}
|
90
|
+
});
|
91
|
+
let L;
|
92
|
+
let Map;
|
93
|
+
let TileLayer;
|
94
|
+
let Marker;
|
95
|
+
|
96
|
+
var _ref = React.createElement(TileLayer, {
|
97
|
+
url: "http://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png"
|
98
|
+
});
|
99
|
+
|
100
|
+
var _ref2 = React.createElement(HiLoader, {
|
101
|
+
loading: true
|
102
|
+
});
|
103
|
+
|
104
|
+
class HiMap extends React.PureComponent {
|
105
|
+
constructor(props) {
|
106
|
+
super(props);
|
107
|
+
this.mounted = false;
|
108
|
+
this.state = {
|
109
|
+
lat: 0,
|
110
|
+
lng: 0,
|
111
|
+
notFound: false,
|
112
|
+
loaded: false,
|
113
|
+
zoom: 16
|
114
|
+
};
|
115
|
+
this.handleClickZoomIn = this.handleClickZoomIn.bind(this);
|
116
|
+
this.handleScrollZoom = this.handleScrollZoom.bind(this);
|
117
|
+
this.handleClickZoomOut = this.handleClickZoomOut.bind(this);
|
118
|
+
this.handleCenter = this.handleCenter.bind(this);
|
119
|
+
} // Loads the libraries once the component mounted to avoid error caused by server-cli rendering.
|
120
|
+
|
121
|
+
|
122
|
+
componentDidMount() {
|
123
|
+
this.mounted = true;
|
124
|
+
this.findCoords();
|
125
|
+
/* eslint-disable */
|
126
|
+
|
127
|
+
L = require('leaflet');
|
128
|
+
Map = require('react-leaflet').Map;
|
129
|
+
Marker = require('react-leaflet').Marker;
|
130
|
+
TileLayer = require('react-leaflet').TileLayer;
|
131
|
+
/* eslint-enable */
|
132
|
+
}
|
133
|
+
|
134
|
+
componentWillUnmount() {
|
135
|
+
this.mounted = false;
|
136
|
+
}
|
137
|
+
|
138
|
+
handleScrollZoom(event) {
|
139
|
+
this.setState({
|
140
|
+
zoom: event.zoom
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
handleClickZoomIn() {
|
145
|
+
this.setState(prevState => {
|
146
|
+
return {
|
147
|
+
zoom: prevState.zoom + 1
|
148
|
+
};
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
handleClickZoomOut() {
|
153
|
+
this.setState(prevState => {
|
154
|
+
return {
|
155
|
+
zoom: prevState.zoom - 1
|
156
|
+
};
|
157
|
+
});
|
158
|
+
}
|
159
|
+
|
160
|
+
handleCenter() {
|
161
|
+
// trick to center the map.
|
162
|
+
this.setState(prevState => {
|
163
|
+
return {
|
164
|
+
lat: prevState.lat + 0.0000000001
|
165
|
+
};
|
166
|
+
});
|
167
|
+
} // Call to the geocoding API.
|
168
|
+
|
169
|
+
|
170
|
+
findCoords() {
|
171
|
+
fetch(`${apiUrl}${this.props.address}&format=jsonv2&limit=5&bounded=1&dedupe=1&namedetails=1`).then(result => result.json()).then(response => {
|
172
|
+
if (this.mounted) {
|
173
|
+
if (response.length !== 0) {
|
174
|
+
this.setState({
|
175
|
+
lat: parseFloat(response[0].lat),
|
176
|
+
lng: parseFloat(response[0].lon),
|
177
|
+
notFound: false,
|
178
|
+
loaded: true
|
179
|
+
});
|
180
|
+
} else {
|
181
|
+
this.setState({
|
182
|
+
notFound: true
|
183
|
+
});
|
184
|
+
this.props.onAddressNotFound();
|
185
|
+
}
|
186
|
+
}
|
187
|
+
});
|
188
|
+
}
|
189
|
+
|
190
|
+
render() {
|
191
|
+
const {
|
192
|
+
zoom,
|
193
|
+
lng,
|
194
|
+
lat,
|
195
|
+
notFound,
|
196
|
+
loaded
|
197
|
+
} = this.state;
|
198
|
+
const {
|
199
|
+
translations,
|
200
|
+
classes
|
201
|
+
} = this.props;
|
202
|
+
const position = [lat, lng];
|
203
|
+
let element;
|
204
|
+
let myIcon;
|
205
|
+
if (notFound) element = translations.notFound;
|
206
|
+
|
207
|
+
if (loaded) {
|
208
|
+
myIcon = L.divIcon({
|
209
|
+
html: '<svg x="0px" y="0px" viewBox="0 0 365 560" enable-background="new 0 0 365 560" xml:space="preserve">\n' + '<path class="map_marker" ' + 'd="M182.9,551.7c0,0.1,0.2,0.3,0.2,0.3S358.3,283,358.3,194.6c0-130.1-88.8-186.7-175.4-186.9 ' + 'C96.3,7.9,7.5,64.5,7.5,194.6c0,88.4,175.3,357.4,175.3,357.4S182.9,551.7,182.9,551.7z' + ' M122.2,187.2c0-33.6,27.2-60.8,60.8-60.8 ' + 'c33.6,0,60.8,27.2,60.8,60.8S216.5,248,182.9,248C149.4,248,122.2,220.8,122.2,187.2z"/>\n' + '</svg>',
|
210
|
+
iconSize: [24, 36],
|
211
|
+
iconAnchor: [11, 36]
|
212
|
+
});
|
213
|
+
element = React.createElement(Map, {
|
214
|
+
zoom: zoom,
|
215
|
+
center: position,
|
216
|
+
className: classes.map,
|
217
|
+
onViewportChange: this.handleScrollZoom
|
218
|
+
}, _ref, React.createElement(Marker, {
|
219
|
+
position: position,
|
220
|
+
icon: myIcon
|
221
|
+
}), React.createElement("div", {
|
222
|
+
className: classes.controlButtons
|
223
|
+
}, React.createElement("div", {
|
224
|
+
className: classes.centerButtonContainer
|
225
|
+
}, React.createElement(HiButton, {
|
226
|
+
className: classes.centerButton,
|
227
|
+
onClick: this.handleCenter
|
228
|
+
}, React.createElement(HiIcon, {
|
229
|
+
className: classes.centerIcon,
|
230
|
+
icon: 'my_location',
|
231
|
+
size: 24
|
232
|
+
}))), React.createElement("div", {
|
233
|
+
className: classes.zoomButtons
|
234
|
+
}, React.createElement(HiButton, {
|
235
|
+
onClick: this.handleClickZoomIn,
|
236
|
+
className: classes.zoomButton
|
237
|
+
}, "+"), React.createElement(HiButton, {
|
238
|
+
onClick: this.handleClickZoomOut,
|
239
|
+
className: classes.zoomButton
|
240
|
+
}, "-"))));
|
241
|
+
} else {
|
242
|
+
element = React.createElement("div", {
|
243
|
+
style: {
|
244
|
+
top: '50%',
|
245
|
+
left: '50%',
|
246
|
+
position: 'absolute'
|
247
|
+
}
|
248
|
+
}, _ref2);
|
249
|
+
}
|
250
|
+
|
251
|
+
return React.createElement("div", {
|
252
|
+
style: {
|
253
|
+
height: '352px',
|
254
|
+
width: '100%',
|
255
|
+
position: 'relative'
|
256
|
+
}
|
257
|
+
}, element);
|
258
|
+
}
|
259
|
+
|
260
|
+
}
|
261
|
+
|
262
|
+
HiMap.defaultProps = {
|
263
|
+
translations: {
|
264
|
+
notFound: 'Address not found'
|
265
|
+
}
|
266
|
+
};
|
267
|
+
HiMap.propTypes = process.env.NODE_ENV !== "production" ? {
|
268
|
+
/**
|
269
|
+
* The address to see in the Map component.
|
270
|
+
*/
|
271
|
+
address: PropTypes.string.isRequired,
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Useful to extend the style applied to components.
|
275
|
+
*/
|
276
|
+
classes: PropTypes.object.isRequired,
|
277
|
+
|
278
|
+
/**
|
279
|
+
* Function to tell the parent composant that the address was not found by the API.
|
280
|
+
*/
|
281
|
+
onAddressNotFound: PropTypes.func,
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Traductions
|
285
|
+
*/
|
286
|
+
translations: PropTypes.object
|
287
|
+
} : {};
|
288
|
+
export default withStyles(styles, {
|
289
|
+
name: 'HmuiHiMap'
|
290
|
+
})(HiMap);
|