@hipay/hipay-material-ui 2.0.0-beta.55 → 2.0.0-beta.57
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +116 -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 +13 -1
- package/HiCell/CellRate.js +6 -3
- package/HiCell/CellSentinel.js +7 -10
- package/HiCell/CellTextStyled.js +29 -1
- package/HiColoredLabel/HiColoredLabel.js +1 -1
- package/HiDatePicker/Caption.js +16 -10
- package/HiDatePicker/HiDatePicker.js +9 -3
- package/HiDatePicker/HiDateRangePicker.js +36 -22
- package/HiDatePicker/HiDateRangeSelector.js +75 -21
- package/HiDatePicker/NavBar.js +8 -1
- package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
- package/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +123 -0
- package/HiDatePicker/Overlays/MonthPickerOverlay.js +4 -4
- 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 +4 -6
- package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/HiDatePicker/hiLocaleUtils.js +144 -0
- package/HiDatePicker/stylesheet.js +33 -7
- 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/HiFormControl.js +2 -0
- package/HiForm/HiInput.js +3 -3
- 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 +96 -0
- package/HiNotice/index.js +23 -0
- package/HiPdfReader/HiPdfReader.js +269 -0
- package/HiPdfReader/index.js +15 -0
- package/HiPin/HiPin.js +1 -1
- package/HiRadio/HiRadio.js +74 -0
- package/HiRadio/index.js +15 -0
- package/HiSelect/HiSelect.js +73 -84
- package/HiSelect/HiSuggestSelect.js +35 -4
- package/HiSelect/SelectInput.js +9 -1
- package/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/HiSelectNew/HiSelect.js +260 -179
- package/HiSelectNew/HiSelectContent.js +0 -8
- package/HiSelectNew/HiSelectInput.js +8 -9
- package/HiSelectableList/HiSelectableList.js +39 -4
- package/HiSelectableList/HiSelectableListItem.js +81 -38
- package/HiTable/HiCellBuilder.js +25 -12
- package/HiTable/HiTableHeader.js +16 -17
- package/HiTable/constants.js +3 -1
- package/README.md +248 -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 +13 -1
- package/es/HiCell/CellRate.js +6 -3
- package/es/HiCell/CellSentinel.js +7 -10
- package/es/HiCell/CellTextStyled.js +28 -1
- package/es/HiColoredLabel/HiColoredLabel.js +1 -1
- package/es/HiDatePicker/Caption.js +14 -10
- package/es/HiDatePicker/HiDatePicker.js +8 -3
- package/es/HiDatePicker/HiDateRangePicker.js +40 -28
- package/es/HiDatePicker/HiDateRangeSelector.js +69 -21
- package/es/HiDatePicker/ListPicker.js +1 -1
- package/es/HiDatePicker/NavBar.js +7 -1
- package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
- package/es/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +106 -0
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +5 -5
- 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 +4 -6
- package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/hiLocaleUtils.js +131 -0
- package/es/HiDatePicker/stylesheet.js +32 -7
- 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/HiFormControl.js +2 -0
- package/es/HiForm/HiInput.js +3 -3
- 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 +78 -0
- package/es/HiNotice/index.js +2 -0
- package/es/HiPdfReader/HiPdfReader.js +214 -0
- package/es/HiPdfReader/index.js +1 -0
- package/es/HiPin/HiPin.js +1 -1
- 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 +30 -4
- package/es/HiSelect/SelectInput.js +9 -1
- package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/es/HiSelectNew/HiSelect.js +246 -162
- package/es/HiSelectNew/HiSelectContent.js +0 -7
- package/es/HiSelectNew/HiSelectInput.js +8 -9
- package/es/HiSelectableList/HiSelectableList.js +34 -6
- package/es/HiSelectableList/HiSelectableListItem.js +92 -40
- package/es/HiTable/HiCellBuilder.js +130 -123
- package/es/HiTable/HiTableHeader.js +14 -12
- package/es/HiTable/constants.js +1 -0
- package/es/index.js +9 -1
- package/es/utils/helpers.js +1 -1
- package/index.es.js +9 -1
- package/index.js +66 -2
- package/package.json +5 -2
- package/umd/hipay-material-ui.development.js +44450 -40930
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +1 -1
@@ -0,0 +1,140 @@
|
|
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 HiFormControl from './HiFormControl';
|
7
|
+
import HiUpload from './HiUpload';
|
8
|
+
export const styles = theme => ({
|
9
|
+
flexContainer: {
|
10
|
+
display: ' flex',
|
11
|
+
alignItems: 'center'
|
12
|
+
},
|
13
|
+
statusIcon: {
|
14
|
+
height: '80px',
|
15
|
+
width: '80px',
|
16
|
+
marginRight: '8px',
|
17
|
+
padding: '24px',
|
18
|
+
borderRadius: '2px',
|
19
|
+
backgroundColor: theme.palette.local.background2,
|
20
|
+
border: `1px solid ${theme.palette.middle.main}`,
|
21
|
+
color: `${theme.palette.middle.main} !important`,
|
22
|
+
fontSize: '80px'
|
23
|
+
},
|
24
|
+
inputContainer: {
|
25
|
+
flex: '1'
|
26
|
+
},
|
27
|
+
empty: {
|
28
|
+
border: `1px solid ${theme.palette.input.bottomLine}`,
|
29
|
+
color: `${theme.palette.neutral.main} !important`
|
30
|
+
},
|
31
|
+
complete: {
|
32
|
+
border: `1px solid ${theme.palette.positive.main}`,
|
33
|
+
color: `${theme.palette.positive.main} !important`,
|
34
|
+
fontSize: '32px'
|
35
|
+
},
|
36
|
+
error: {
|
37
|
+
border: `1px solid ${theme.palette.negative.main}`,
|
38
|
+
color: `${theme.palette.negative.main} !important`
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
class HiUploadField extends React.PureComponent {
|
43
|
+
render() {
|
44
|
+
const _this$props = this.props,
|
45
|
+
{
|
46
|
+
className,
|
47
|
+
label,
|
48
|
+
helperIcon,
|
49
|
+
helperText,
|
50
|
+
values
|
51
|
+
} = _this$props,
|
52
|
+
others = _objectWithoutProperties(_this$props, ["className", "label", "helperIcon", "helperText", "values"]);
|
53
|
+
|
54
|
+
let empty = true;
|
55
|
+
let error = false;
|
56
|
+
let errorText = '';
|
57
|
+
|
58
|
+
for (let i = 0, len = values.length; i < len; i += 1) {
|
59
|
+
const value = values[i];
|
60
|
+
|
61
|
+
if (value !== undefined) {
|
62
|
+
empty = value.value !== null && !value.error ? false : empty;
|
63
|
+
error = value.error || error;
|
64
|
+
errorText = errorText || value.errorMessage;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
return React.createElement(HiFormControl, {
|
69
|
+
label: label,
|
70
|
+
className: className,
|
71
|
+
errorText: errorText,
|
72
|
+
error: error,
|
73
|
+
helperIcon: helperIcon,
|
74
|
+
helperText: helperText
|
75
|
+
}, React.createElement(HiUpload, _extends({
|
76
|
+
values: values
|
77
|
+
}, others)));
|
78
|
+
}
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
HiUploadField.defaultProps = {
|
83
|
+
helperText: '',
|
84
|
+
helperIcon: false
|
85
|
+
};
|
86
|
+
HiUploadField.propTypes = process.env.NODE_ENV !== "production" ? {
|
87
|
+
/**
|
88
|
+
* Useful to extend the style applied to components.
|
89
|
+
*/
|
90
|
+
classes: PropTypes.object,
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Classes CSS appliquées.
|
94
|
+
*/
|
95
|
+
className: PropTypes.string,
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
99
|
+
*/
|
100
|
+
helperIcon: PropTypes.bool,
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Texte de l'aide
|
104
|
+
*/
|
105
|
+
helperText: PropTypes.string,
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Array containing each of the inputs the component has to show (represented by an object).
|
109
|
+
*/
|
110
|
+
inputs: PropTypes.array.isRequired,
|
111
|
+
|
112
|
+
/**
|
113
|
+
* The label of the global input.
|
114
|
+
*/
|
115
|
+
label: PropTypes.string,
|
116
|
+
|
117
|
+
/**
|
118
|
+
* The method given to change the file.
|
119
|
+
*/
|
120
|
+
onChange: PropTypes.func,
|
121
|
+
|
122
|
+
/**
|
123
|
+
* The method to delete a file.
|
124
|
+
*/
|
125
|
+
onDeleteFile: PropTypes.func,
|
126
|
+
|
127
|
+
/**
|
128
|
+
* The method given to see the file.
|
129
|
+
*/
|
130
|
+
onSeeFile: PropTypes.func,
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Valeurs des inputs
|
134
|
+
*/
|
135
|
+
values: PropTypes.array
|
136
|
+
} : {};
|
137
|
+
export default withStyles(styles, {
|
138
|
+
hiComponent: true,
|
139
|
+
name: 'HmuiHiUploadField'
|
140
|
+
})(HiUploadField);
|
@@ -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';
|