@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.
- 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,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import withStyles from '../styles/withStyles';
|
|
4
|
+
import HiDot from './HiDot';
|
|
5
|
+
export const styles = () => ({
|
|
6
|
+
dotStepper: {
|
|
7
|
+
width: '100%',
|
|
8
|
+
maxWidth: 200,
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
flexWrap: 'nowrap',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
alignItems: 'center'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
class HiDotsStepper extends React.PureComponent {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
|
|
21
|
+
this.handleClick = activeStep => () => {
|
|
22
|
+
this.props.onChange(activeStep);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this.handleNavigation = e => {
|
|
26
|
+
const {
|
|
27
|
+
activeStep,
|
|
28
|
+
steps
|
|
29
|
+
} = this.props;
|
|
30
|
+
let nextStep = activeStep;
|
|
31
|
+
if (e.key === 'ArrowLeft') nextStep -= 1;
|
|
32
|
+
if (e.key === 'ArrowRight') nextStep += 1;
|
|
33
|
+
nextStep = (nextStep + steps.length) % steps.length; // Permet la navigation d'un Dot au suivant / précédent
|
|
34
|
+
|
|
35
|
+
document.querySelector(`button[tabIndex="${nextStep}"]`).focus();
|
|
36
|
+
this.props.onChange(nextStep);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.handleClick = this.handleClick.bind(this);
|
|
40
|
+
this.handleNavigation = this.handleNavigation.bind(this);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
const {
|
|
45
|
+
classes,
|
|
46
|
+
activeStep,
|
|
47
|
+
steps
|
|
48
|
+
} = this.props;
|
|
49
|
+
return React.createElement("div", {
|
|
50
|
+
role: "presentation",
|
|
51
|
+
className: classes.dotStepper,
|
|
52
|
+
onKeyDown: this.handleNavigation
|
|
53
|
+
}, steps.map((step, idx) => React.createElement(HiDot, {
|
|
54
|
+
key: step.id,
|
|
55
|
+
tabIndex: step.id,
|
|
56
|
+
status: step.status,
|
|
57
|
+
active: idx === activeStep,
|
|
58
|
+
onClick: this.handleClick(idx)
|
|
59
|
+
})));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
HiDotsStepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
65
|
+
activeStep: PropTypes.number.isRequired,
|
|
66
|
+
classes: PropTypes.object,
|
|
67
|
+
onChange: PropTypes.func,
|
|
68
|
+
steps: PropTypes.array.isRequired
|
|
69
|
+
} : {};
|
|
70
|
+
export default withStyles(styles, {
|
|
71
|
+
hiComponent: true,
|
|
72
|
+
name: 'HmuiHiDotsStepper'
|
|
73
|
+
})(HiDotsStepper);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
// @inheritedComponent HiSuggestSelectField
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import HiSuggestSelectField from '../HiSelect/HiSuggestSelectField'; // OpenStreeMap API url
|
|
7
|
+
|
|
8
|
+
const API_URL = 'https://nominatim.openstreetmap.org/search?q=';
|
|
9
|
+
/**
|
|
10
|
+
* Champs input adresse pour formulaire
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class HiAddressField extends React.Component {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
|
|
17
|
+
this.displaySuggestions = predictions => {
|
|
18
|
+
const options = [];
|
|
19
|
+
let isExact = false;
|
|
20
|
+
predictions.forEach(prediction => {
|
|
21
|
+
// Si le texte saisi est identique à une des propositions, on estime que la valeur de l'adresse est exacte.
|
|
22
|
+
isExact = prediction.display_name === this.state.inputValue ? true : isExact;
|
|
23
|
+
options.push({
|
|
24
|
+
id: prediction.place_id,
|
|
25
|
+
label: prediction.display_name,
|
|
26
|
+
labelHighlight: prediction.display_name.replace(new RegExp(this.value, 'gi'), '<strong>$&</strong>'),
|
|
27
|
+
// Liste des types d'adresse : https://github.com/openstreetmap/Nominatim/blob/80df4d3b560f5b1fd550dcf8cdc09a992b69fee0/settings/partitionedtags.def
|
|
28
|
+
icon: ['amenity', 'building'].includes(prediction.category) ? 'domain' : 'place',
|
|
29
|
+
type: 'icon',
|
|
30
|
+
key: prediction.id
|
|
31
|
+
});
|
|
32
|
+
}, this);
|
|
33
|
+
this.setState({
|
|
34
|
+
options,
|
|
35
|
+
isExact
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.state = {
|
|
40
|
+
inputValue: null,
|
|
41
|
+
options: [],
|
|
42
|
+
isExact: false
|
|
43
|
+
};
|
|
44
|
+
this.handleSearch = this.handleSearch.bind(this);
|
|
45
|
+
this.handleSelect = this.handleSelect.bind(this);
|
|
46
|
+
this.handleReset = this.handleReset.bind(this);
|
|
47
|
+
this.displaySuggestions = this.displaySuggestions.bind(this);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
handleSearch(event) {
|
|
51
|
+
if (event.target.value) {
|
|
52
|
+
this.setState({
|
|
53
|
+
inputValue: event.target.value
|
|
54
|
+
});
|
|
55
|
+
fetch(`${API_URL} + ${this.state.inputValue} + &format=jsonv2&limit=5&bounded=1&dedupe=1&namedetails=1`).then(result => result.json()).then(data => {
|
|
56
|
+
this.displaySuggestions(data, 'OK');
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
this.setState({
|
|
60
|
+
options: []
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.props.onSearch(event);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
handleReset() {
|
|
68
|
+
this.props.onReset();
|
|
69
|
+
this.setState({
|
|
70
|
+
options: [],
|
|
71
|
+
isExact: false
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
handleSelect(event, value) {
|
|
76
|
+
// Mise à jour de la valeur du champ + la valeur de l'adresse est exacte
|
|
77
|
+
this.setState({
|
|
78
|
+
options: [],
|
|
79
|
+
isExact: true
|
|
80
|
+
});
|
|
81
|
+
this.props.onSelect(event, value.label);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
const _this$props = this.props,
|
|
86
|
+
{
|
|
87
|
+
exactOnly,
|
|
88
|
+
onSearch,
|
|
89
|
+
onReset,
|
|
90
|
+
onSelect
|
|
91
|
+
} = _this$props,
|
|
92
|
+
otherProps = _objectWithoutProperties(_this$props, ["exactOnly", "onSearch", "onReset", "onSelect"]);
|
|
93
|
+
|
|
94
|
+
const {
|
|
95
|
+
options,
|
|
96
|
+
isExact
|
|
97
|
+
} = this.state; // On met le champ en erreur si une adresse exacte est éxigée
|
|
98
|
+
// et si l'adresse courante n'est pas complète
|
|
99
|
+
|
|
100
|
+
const showError = exactOnly && !isExact;
|
|
101
|
+
return React.createElement(HiSuggestSelectField, _extends({
|
|
102
|
+
error: showError,
|
|
103
|
+
options: options,
|
|
104
|
+
onSearch: this.handleSearch,
|
|
105
|
+
onSelect: this.handleSelect,
|
|
106
|
+
onReset: this.handleReset,
|
|
107
|
+
isExact: isExact
|
|
108
|
+
}, otherProps));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
HiAddressField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
114
|
+
/**
|
|
115
|
+
* Est-ce qu'on n'accepte que les adresses trouvées par GMaps
|
|
116
|
+
*/
|
|
117
|
+
exactOnly: PropTypes.bool,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Callback function called to empty the field.
|
|
121
|
+
*/
|
|
122
|
+
onReset: PropTypes.func,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Callback function called when we write in the input.
|
|
126
|
+
*/
|
|
127
|
+
onSearch: PropTypes.func,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Callback function called when a suggestion is selected.
|
|
131
|
+
*/
|
|
132
|
+
onSelect: PropTypes.func
|
|
133
|
+
} : {};
|
|
134
|
+
export default HiAddressField;
|
package/es/HiForm/HiInput.js
CHANGED
|
@@ -89,10 +89,10 @@ export const styles = theme => ({
|
|
|
89
89
|
padding: 0
|
|
90
90
|
}),
|
|
91
91
|
inputText: {
|
|
92
|
-
height:
|
|
92
|
+
height: 40
|
|
93
93
|
},
|
|
94
94
|
inputTextArea: {
|
|
95
|
-
minHeight:
|
|
95
|
+
minHeight: 40,
|
|
96
96
|
paddingTop: 8
|
|
97
97
|
},
|
|
98
98
|
iconPointer: {
|
|
@@ -100,7 +100,7 @@ export const styles = theme => ({
|
|
|
100
100
|
cursor: 'pointer'
|
|
101
101
|
},
|
|
102
102
|
eraseButton: {
|
|
103
|
-
height:
|
|
103
|
+
height: 40,
|
|
104
104
|
width: 40,
|
|
105
105
|
display: 'inline-block'
|
|
106
106
|
},
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import withStyles from '../styles/withStyles';
|
|
4
|
+
import HiFormControl from './HiFormControl';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import HiIcon from '../HiIcon/HiIcon';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
export const styles = theme => ({
|
|
9
|
+
barContainer: {
|
|
10
|
+
width: '100%',
|
|
11
|
+
position: 'relative',
|
|
12
|
+
margin: '0 7px'
|
|
13
|
+
},
|
|
14
|
+
barHidden: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
opacity: 0,
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: '7px',
|
|
19
|
+
zIndex: '2',
|
|
20
|
+
cursor: 'pointer'
|
|
21
|
+
},
|
|
22
|
+
mainContainer: _objectSpread({}, theme.typography.body1, {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexWrap: 'nowrap',
|
|
25
|
+
alignItems: 'center'
|
|
26
|
+
}),
|
|
27
|
+
topContainer: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexWrap: 'nowrap',
|
|
30
|
+
height: '18px'
|
|
31
|
+
},
|
|
32
|
+
bottomContainer: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexWrap: 'nowrap',
|
|
35
|
+
height: '18px'
|
|
36
|
+
},
|
|
37
|
+
barValue: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
width: '100%',
|
|
40
|
+
height: '4px',
|
|
41
|
+
borderRadius: '2px',
|
|
42
|
+
backgroundColor: theme.palette.primary.main,
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
zIndex: '2'
|
|
45
|
+
},
|
|
46
|
+
arrow: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
zIndex: '1',
|
|
49
|
+
transform: 'rotate(-90deg) translate(0%,-50%)',
|
|
50
|
+
transition: 'transform 300ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
51
|
+
transitionProperty: 'transform color',
|
|
52
|
+
fontSize: 20,
|
|
53
|
+
cursor: 'pointer'
|
|
54
|
+
},
|
|
55
|
+
leftLabel: {
|
|
56
|
+
color: theme.palette.primary.main,
|
|
57
|
+
left: '0px',
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
fontSize: '11px',
|
|
60
|
+
alignSelf: 'flex-end'
|
|
61
|
+
},
|
|
62
|
+
rightLabel: {
|
|
63
|
+
color: '#737373',
|
|
64
|
+
right: '0px',
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
fontSize: '11px',
|
|
67
|
+
alignSelf: 'flex-end'
|
|
68
|
+
},
|
|
69
|
+
textValue: {
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
zIndex: '2'
|
|
72
|
+
},
|
|
73
|
+
trackAfter: {
|
|
74
|
+
backgroundColor: 'gray',
|
|
75
|
+
opacity: 0.24
|
|
76
|
+
},
|
|
77
|
+
focused: {
|
|
78
|
+
fontSize: 24,
|
|
79
|
+
color: theme.palette.primary.dark
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* HiSlider component
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
class HiSlider extends React.Component {
|
|
87
|
+
constructor(props) {
|
|
88
|
+
super(props);
|
|
89
|
+
|
|
90
|
+
this.handleChange = event => {
|
|
91
|
+
this.props.onChange(parseFloat(event.target.value));
|
|
92
|
+
this.textValueWidth = this.textValue.offsetWidth;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
this.handleFocus = isFocused => () => {
|
|
96
|
+
this.setState({
|
|
97
|
+
focused: isFocused
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
this.state = {
|
|
102
|
+
focused: false
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Measures several components once they are mounted.
|
|
107
|
+
* If the value and a label (left or right) are hovered,
|
|
108
|
+
* we hide this label.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
componentDidMount() {
|
|
113
|
+
this.leftLabelWidth = this.leftLabel.offsetWidth;
|
|
114
|
+
this.rightLabelWidth = this.rightLabel.offsetWidth;
|
|
115
|
+
this.textValueWidth = this.textValue.offsetWidth;
|
|
116
|
+
this.barContainerWidth = this.barContainer.offsetWidth;
|
|
117
|
+
const {
|
|
118
|
+
hoveringLeft,
|
|
119
|
+
hoveringRight
|
|
120
|
+
} = this.getHovering();
|
|
121
|
+
|
|
122
|
+
if (hoveringLeft || hoveringRight) {
|
|
123
|
+
this.forceUpdate();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Calculates if the labels are hovered.
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
getHovering() {
|
|
132
|
+
const ratio = (this.props.value - this.props.min) / (this.props.max - this.props.min);
|
|
133
|
+
const hoveringLeft = this.leftLabelWidth - (ratio * this.barContainerWidth - ratio * this.textValueWidth) > 0;
|
|
134
|
+
const hoveringRight = this.barContainerWidth - ratio * this.barContainerWidth - this.rightLabelWidth - (1 - ratio) * this.textValueWidth < 0;
|
|
135
|
+
return {
|
|
136
|
+
hoveringLeft,
|
|
137
|
+
hoveringRight
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
render() {
|
|
142
|
+
const {
|
|
143
|
+
classes,
|
|
144
|
+
className,
|
|
145
|
+
min,
|
|
146
|
+
max,
|
|
147
|
+
leftLabel,
|
|
148
|
+
rightLabel,
|
|
149
|
+
step,
|
|
150
|
+
suffix,
|
|
151
|
+
id,
|
|
152
|
+
label,
|
|
153
|
+
value,
|
|
154
|
+
theme
|
|
155
|
+
} = this.props;
|
|
156
|
+
const {
|
|
157
|
+
focused
|
|
158
|
+
} = this.state;
|
|
159
|
+
const ratio = (value - min) / (max - min);
|
|
160
|
+
const percentage = ratio * 100;
|
|
161
|
+
const {
|
|
162
|
+
hoveringLeft,
|
|
163
|
+
hoveringRight
|
|
164
|
+
} = this.getHovering();
|
|
165
|
+
const barColor = focused ? theme.palette.primary.dark : theme.palette.primary.main;
|
|
166
|
+
return (// HiFormControl pour l'affichage du label
|
|
167
|
+
React.createElement(HiFormControl, {
|
|
168
|
+
id: id,
|
|
169
|
+
label: label,
|
|
170
|
+
className: className,
|
|
171
|
+
onFocus: this.handleFocus(true),
|
|
172
|
+
onBlur: this.handleFocus(false)
|
|
173
|
+
}, React.createElement("div", {
|
|
174
|
+
className: classes.mainContainer
|
|
175
|
+
}, React.createElement("div", null, min, suffix), React.createElement("div", {
|
|
176
|
+
className: classes.barContainer,
|
|
177
|
+
ref: div => {
|
|
178
|
+
this.barContainer = div;
|
|
179
|
+
}
|
|
180
|
+
}, React.createElement("div", {
|
|
181
|
+
className: classes.topContainer
|
|
182
|
+
}, !hoveringLeft && React.createElement("div", {
|
|
183
|
+
className: classes.leftLabel,
|
|
184
|
+
ref: div => {
|
|
185
|
+
this.leftLabel = div;
|
|
186
|
+
}
|
|
187
|
+
}, leftLabel), React.createElement("div", {
|
|
188
|
+
className: classes.textValue,
|
|
189
|
+
style: {
|
|
190
|
+
left: `${percentage}%`,
|
|
191
|
+
transform: `translate(-${percentage}%)`
|
|
192
|
+
},
|
|
193
|
+
ref: div => {
|
|
194
|
+
this.textValue = div;
|
|
195
|
+
}
|
|
196
|
+
}, value, suffix), !hoveringRight && React.createElement("div", {
|
|
197
|
+
className: classes.rightLabel,
|
|
198
|
+
ref: div => {
|
|
199
|
+
this.rightLabel = div;
|
|
200
|
+
}
|
|
201
|
+
}, rightLabel)), React.createElement("div", {
|
|
202
|
+
className: classes.barValue,
|
|
203
|
+
style: {
|
|
204
|
+
background: `linear-gradient(to right, ${barColor}, ${barColor} ${percentage}%, #E0E0E0 ${percentage}%, #E0E0E0)`
|
|
205
|
+
}
|
|
206
|
+
}), React.createElement("input", {
|
|
207
|
+
type: 'range',
|
|
208
|
+
min: min,
|
|
209
|
+
max: max,
|
|
210
|
+
value: value,
|
|
211
|
+
onChange: this.handleChange,
|
|
212
|
+
className: classes.barHidden,
|
|
213
|
+
step: step
|
|
214
|
+
}), React.createElement("div", {
|
|
215
|
+
className: classes.bottomContainer
|
|
216
|
+
}, React.createElement(HiIcon, {
|
|
217
|
+
className: classNames(classes.arrow, {
|
|
218
|
+
[classes.focused]: focused
|
|
219
|
+
}),
|
|
220
|
+
icon: 'play_arrow',
|
|
221
|
+
style: {
|
|
222
|
+
left: `${percentage}%`,
|
|
223
|
+
color: barColor
|
|
224
|
+
}
|
|
225
|
+
}))), React.createElement("div", null, max, suffix)))
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
HiSlider.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
232
|
+
/**
|
|
233
|
+
* Useful to extend the style applied to components.
|
|
234
|
+
*/
|
|
235
|
+
classes: PropTypes.object,
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Classes CSS appliquées.
|
|
239
|
+
*/
|
|
240
|
+
className: PropTypes.string,
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Id de l'élément input
|
|
244
|
+
*/
|
|
245
|
+
id: PropTypes.string.isRequired,
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Label du champ
|
|
249
|
+
*/
|
|
250
|
+
label: PropTypes.string,
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The label to show on the left.
|
|
254
|
+
*/
|
|
255
|
+
leftLabel: PropTypes.string,
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* The Maximum value for the slider.
|
|
259
|
+
*/
|
|
260
|
+
max: PropTypes.number.isRequired,
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The Minimum value for the slider.
|
|
264
|
+
*/
|
|
265
|
+
min: PropTypes.number.isRequired,
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Fonction de callback appelée lorsqu'on change la valeur du slider.
|
|
269
|
+
*/
|
|
270
|
+
onChange: PropTypes.func,
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The label to show on the right
|
|
274
|
+
*/
|
|
275
|
+
rightLabel: PropTypes.string,
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The step between two selectable values.
|
|
279
|
+
*/
|
|
280
|
+
step: PropTypes.number,
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The suffix to show after each number.
|
|
284
|
+
*/
|
|
285
|
+
suffix: PropTypes.string,
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @ignore
|
|
289
|
+
*/
|
|
290
|
+
theme: PropTypes.object,
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The
|
|
294
|
+
* value of the input.
|
|
295
|
+
*/
|
|
296
|
+
value: PropTypes.number
|
|
297
|
+
} : {};
|
|
298
|
+
export default withStyles(styles, {
|
|
299
|
+
hiComponent: true,
|
|
300
|
+
name: 'HiSlider',
|
|
301
|
+
withTheme: true
|
|
302
|
+
})(HiSlider);
|
|
@@ -0,0 +1,158 @@
|
|
|
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 classNames from 'classnames';
|
|
6
|
+
import withStyles from '../styles/withStyles';
|
|
7
|
+
import HiUploadInput from './HiUploadInput';
|
|
8
|
+
import HiIcon from '../HiIcon';
|
|
9
|
+
export const styles = theme => ({
|
|
10
|
+
flexContainer: {
|
|
11
|
+
display: ' flex',
|
|
12
|
+
alignItems: 'center'
|
|
13
|
+
},
|
|
14
|
+
statusIcon: {
|
|
15
|
+
height: '80px',
|
|
16
|
+
width: '80px',
|
|
17
|
+
marginRight: '8px',
|
|
18
|
+
padding: '24px',
|
|
19
|
+
borderRadius: '2px',
|
|
20
|
+
backgroundColor: theme.palette.local.background2,
|
|
21
|
+
border: `1px solid ${theme.palette.middle.main}`,
|
|
22
|
+
color: `${theme.palette.middle.main} !important`,
|
|
23
|
+
fontSize: '80px'
|
|
24
|
+
},
|
|
25
|
+
inputContainer: {
|
|
26
|
+
flex: '1'
|
|
27
|
+
},
|
|
28
|
+
empty: {
|
|
29
|
+
border: `1px solid ${theme.palette.input.bottomLine}`,
|
|
30
|
+
color: `${theme.palette.neutral.main} !important`
|
|
31
|
+
},
|
|
32
|
+
complete: {
|
|
33
|
+
border: `1px solid ${theme.palette.positive.main}`,
|
|
34
|
+
color: `${theme.palette.positive.main} !important`,
|
|
35
|
+
fontSize: '32px'
|
|
36
|
+
},
|
|
37
|
+
error: {
|
|
38
|
+
border: `1px solid ${theme.palette.negative.main}`,
|
|
39
|
+
color: `${theme.palette.negative.main} !important`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
class HiUpload extends React.PureComponent {
|
|
44
|
+
render() {
|
|
45
|
+
const _this$props = this.props,
|
|
46
|
+
{
|
|
47
|
+
inputs,
|
|
48
|
+
classes,
|
|
49
|
+
values
|
|
50
|
+
} = _this$props,
|
|
51
|
+
others = _objectWithoutProperties(_this$props, ["inputs", "classes", "values"]);
|
|
52
|
+
|
|
53
|
+
let complete = true;
|
|
54
|
+
let empty = true;
|
|
55
|
+
let error = false;
|
|
56
|
+
|
|
57
|
+
for (let i = 0, len = values.length; i < len; i += 1) {
|
|
58
|
+
const value = values[i];
|
|
59
|
+
|
|
60
|
+
if (value !== undefined) {
|
|
61
|
+
complete = value.value === null || value.error ? false : complete;
|
|
62
|
+
empty = value.value !== null && !value.error ? false : empty;
|
|
63
|
+
error = value.error || error;
|
|
64
|
+
} else {
|
|
65
|
+
complete = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const statusClass = classNames(classes.statusIcon, {
|
|
70
|
+
[classes.empty]: empty,
|
|
71
|
+
[classes.complete]: complete,
|
|
72
|
+
[classes.error]: error
|
|
73
|
+
});
|
|
74
|
+
let icon;
|
|
75
|
+
|
|
76
|
+
if (error) {
|
|
77
|
+
icon = 'warning';
|
|
78
|
+
} else if (complete) {
|
|
79
|
+
icon = 'check_circle';
|
|
80
|
+
} else {
|
|
81
|
+
icon = 'file_upload';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return React.createElement("div", {
|
|
85
|
+
className: classes.flexContainer
|
|
86
|
+
}, React.createElement(HiIcon, {
|
|
87
|
+
className: statusClass,
|
|
88
|
+
icon: icon,
|
|
89
|
+
size: 32
|
|
90
|
+
}), React.createElement("div", {
|
|
91
|
+
className: classes.inputContainer
|
|
92
|
+
}, inputs.map((item, index) => React.createElement(HiUploadInput, _extends({
|
|
93
|
+
maxSize: item.maxSize,
|
|
94
|
+
acceptedTypes: item.acceptedTypes,
|
|
95
|
+
placeholder: item.placeholder,
|
|
96
|
+
value: values[index] ? values[index].value : null,
|
|
97
|
+
error: values[index] ? values[index].error : null,
|
|
98
|
+
errorMessage: values[index] ? values[index].errorMessage : null,
|
|
99
|
+
onSeeFile: this.handleSeeFile,
|
|
100
|
+
onDeleteFile: this.props.onDeleteFile,
|
|
101
|
+
onChange: this.props.onChange,
|
|
102
|
+
index: index,
|
|
103
|
+
key: item.id
|
|
104
|
+
}, others)))));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
HiUpload.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
110
|
+
/**
|
|
111
|
+
* Useful to extend the style applied to components.
|
|
112
|
+
*/
|
|
113
|
+
classes: PropTypes.object,
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Classes CSS appliquées.
|
|
117
|
+
*/
|
|
118
|
+
className: PropTypes.string,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
|
122
|
+
*/
|
|
123
|
+
helperIcon: PropTypes.bool,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Texte de l'aide
|
|
127
|
+
*/
|
|
128
|
+
helperText: PropTypes.string,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Array containing each of the inputs the component has to show (represented by an object).
|
|
132
|
+
*/
|
|
133
|
+
inputs: PropTypes.array.isRequired,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The method given to change the file.
|
|
137
|
+
*/
|
|
138
|
+
onChange: PropTypes.func,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The method to delete a file.
|
|
142
|
+
*/
|
|
143
|
+
onDeleteFile: PropTypes.func,
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The method given to see the file.
|
|
147
|
+
*/
|
|
148
|
+
onSeeFile: PropTypes.func,
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Valeurs des inputs
|
|
152
|
+
*/
|
|
153
|
+
values: PropTypes.array
|
|
154
|
+
} : {};
|
|
155
|
+
export default withStyles(styles, {
|
|
156
|
+
hiComponent: true,
|
|
157
|
+
name: 'HmuiHiUpload'
|
|
158
|
+
})(HiUpload);
|