@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,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
+
|
|
30
|
+
var _HiSuggestSelectField = _interopRequireDefault(require("../HiSelect/HiSuggestSelectField"));
|
|
31
|
+
|
|
32
|
+
// @inheritedComponent HiSuggestSelectField
|
|
33
|
+
// OpenStreeMap API url
|
|
34
|
+
var API_URL = 'https://nominatim.openstreetmap.org/search?q=';
|
|
35
|
+
/**
|
|
36
|
+
* Champs input adresse pour formulaire
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
var HiAddressField =
|
|
40
|
+
/*#__PURE__*/
|
|
41
|
+
function (_React$Component) {
|
|
42
|
+
(0, _inherits2.default)(HiAddressField, _React$Component);
|
|
43
|
+
|
|
44
|
+
function HiAddressField(props) {
|
|
45
|
+
var _this;
|
|
46
|
+
|
|
47
|
+
(0, _classCallCheck2.default)(this, HiAddressField);
|
|
48
|
+
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiAddressField).call(this, props));
|
|
49
|
+
|
|
50
|
+
_this.displaySuggestions = function (predictions) {
|
|
51
|
+
var options = [];
|
|
52
|
+
var isExact = false;
|
|
53
|
+
predictions.forEach(function (prediction) {
|
|
54
|
+
// Si le texte saisi est identique à une des propositions, on estime que la valeur de l'adresse est exacte.
|
|
55
|
+
isExact = prediction.display_name === _this.state.inputValue ? true : isExact;
|
|
56
|
+
options.push({
|
|
57
|
+
id: prediction.place_id,
|
|
58
|
+
label: prediction.display_name,
|
|
59
|
+
labelHighlight: prediction.display_name.replace(new RegExp(_this.value, 'gi'), '<strong>$&</strong>'),
|
|
60
|
+
// Liste des types d'adresse : https://github.com/openstreetmap/Nominatim/blob/80df4d3b560f5b1fd550dcf8cdc09a992b69fee0/settings/partitionedtags.def
|
|
61
|
+
icon: ['amenity', 'building'].includes(prediction.category) ? 'domain' : 'place',
|
|
62
|
+
type: 'icon',
|
|
63
|
+
key: prediction.id
|
|
64
|
+
});
|
|
65
|
+
}, (0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
66
|
+
|
|
67
|
+
_this.setState({
|
|
68
|
+
options: options,
|
|
69
|
+
isExact: isExact
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
_this.state = {
|
|
74
|
+
inputValue: null,
|
|
75
|
+
options: [],
|
|
76
|
+
isExact: false
|
|
77
|
+
};
|
|
78
|
+
_this.handleSearch = _this.handleSearch.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
79
|
+
_this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
80
|
+
_this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
81
|
+
_this.displaySuggestions = _this.displaySuggestions.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
(0, _createClass2.default)(HiAddressField, [{
|
|
86
|
+
key: "handleSearch",
|
|
87
|
+
value: function handleSearch(event) {
|
|
88
|
+
var _this2 = this;
|
|
89
|
+
|
|
90
|
+
if (event.target.value) {
|
|
91
|
+
this.setState({
|
|
92
|
+
inputValue: event.target.value
|
|
93
|
+
});
|
|
94
|
+
fetch("".concat(API_URL, " + ").concat(this.state.inputValue, " + &format=jsonv2&limit=5&bounded=1&dedupe=1&namedetails=1")).then(function (result) {
|
|
95
|
+
return result.json();
|
|
96
|
+
}).then(function (data) {
|
|
97
|
+
_this2.displaySuggestions(data, 'OK');
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
this.setState({
|
|
101
|
+
options: []
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.props.onSearch(event);
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "handleReset",
|
|
109
|
+
value: function handleReset() {
|
|
110
|
+
this.props.onReset();
|
|
111
|
+
this.setState({
|
|
112
|
+
options: [],
|
|
113
|
+
isExact: false
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "handleSelect",
|
|
118
|
+
value: function handleSelect(event, value) {
|
|
119
|
+
// Mise à jour de la valeur du champ + la valeur de l'adresse est exacte
|
|
120
|
+
this.setState({
|
|
121
|
+
options: [],
|
|
122
|
+
isExact: true
|
|
123
|
+
});
|
|
124
|
+
this.props.onSelect(event, value.label);
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "render",
|
|
128
|
+
value: function render() {
|
|
129
|
+
var _this$props = this.props,
|
|
130
|
+
exactOnly = _this$props.exactOnly,
|
|
131
|
+
onSearch = _this$props.onSearch,
|
|
132
|
+
onReset = _this$props.onReset,
|
|
133
|
+
onSelect = _this$props.onSelect,
|
|
134
|
+
otherProps = (0, _objectWithoutProperties2.default)(_this$props, ["exactOnly", "onSearch", "onReset", "onSelect"]);
|
|
135
|
+
var _this$state = this.state,
|
|
136
|
+
options = _this$state.options,
|
|
137
|
+
isExact = _this$state.isExact; // On met le champ en erreur si une adresse exacte est éxigée
|
|
138
|
+
// et si l'adresse courante n'est pas complète
|
|
139
|
+
|
|
140
|
+
var showError = exactOnly && !isExact;
|
|
141
|
+
return _react.default.createElement(_HiSuggestSelectField.default, (0, _extends2.default)({
|
|
142
|
+
error: showError,
|
|
143
|
+
options: options,
|
|
144
|
+
onSearch: this.handleSearch,
|
|
145
|
+
onSelect: this.handleSelect,
|
|
146
|
+
onReset: this.handleReset,
|
|
147
|
+
isExact: isExact
|
|
148
|
+
}, otherProps));
|
|
149
|
+
}
|
|
150
|
+
}]);
|
|
151
|
+
return HiAddressField;
|
|
152
|
+
}(_react.default.Component);
|
|
153
|
+
|
|
154
|
+
HiAddressField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
155
|
+
/**
|
|
156
|
+
* Est-ce qu'on n'accepte que les adresses trouvées par GMaps
|
|
157
|
+
*/
|
|
158
|
+
exactOnly: _propTypes.default.bool,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Callback function called to empty the field.
|
|
162
|
+
*/
|
|
163
|
+
onReset: _propTypes.default.func,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Callback function called when we write in the input.
|
|
167
|
+
*/
|
|
168
|
+
onSearch: _propTypes.default.func,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Callback function called when a suggestion is selected.
|
|
172
|
+
*/
|
|
173
|
+
onSelect: _propTypes.default.func
|
|
174
|
+
} : {};
|
|
175
|
+
var _default = HiAddressField;
|
|
176
|
+
exports.default = _default;
|
package/HiForm/HiFormControl.js
CHANGED
package/HiForm/HiInput.js
CHANGED
|
@@ -121,10 +121,10 @@ var styles = function styles(theme) {
|
|
|
121
121
|
padding: 0
|
|
122
122
|
}),
|
|
123
123
|
inputText: {
|
|
124
|
-
height:
|
|
124
|
+
height: 40
|
|
125
125
|
},
|
|
126
126
|
inputTextArea: {
|
|
127
|
-
minHeight:
|
|
127
|
+
minHeight: 40,
|
|
128
128
|
paddingTop: 8
|
|
129
129
|
},
|
|
130
130
|
iconPointer: {
|
|
@@ -132,7 +132,7 @@ var styles = function styles(theme) {
|
|
|
132
132
|
cursor: 'pointer'
|
|
133
133
|
},
|
|
134
134
|
eraseButton: {
|
|
135
|
-
height:
|
|
135
|
+
height: 40,
|
|
136
136
|
width: 40,
|
|
137
137
|
display: 'inline-block'
|
|
138
138
|
},
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.styles = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
|
27
|
+
|
|
28
|
+
var _HiFormControl = _interopRequireDefault(require("./HiFormControl"));
|
|
29
|
+
|
|
30
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
+
|
|
32
|
+
var _HiIcon = _interopRequireDefault(require("../HiIcon/HiIcon"));
|
|
33
|
+
|
|
34
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
35
|
+
|
|
36
|
+
var styles = function styles(theme) {
|
|
37
|
+
return {
|
|
38
|
+
barContainer: {
|
|
39
|
+
width: '100%',
|
|
40
|
+
position: 'relative',
|
|
41
|
+
margin: '0 7px'
|
|
42
|
+
},
|
|
43
|
+
barHidden: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
opacity: 0,
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
top: '7px',
|
|
48
|
+
zIndex: '2',
|
|
49
|
+
cursor: 'pointer'
|
|
50
|
+
},
|
|
51
|
+
mainContainer: (0, _extends2.default)({}, theme.typography.body1, {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexWrap: 'nowrap',
|
|
54
|
+
alignItems: 'center'
|
|
55
|
+
}),
|
|
56
|
+
topContainer: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flexWrap: 'nowrap',
|
|
59
|
+
height: '18px'
|
|
60
|
+
},
|
|
61
|
+
bottomContainer: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexWrap: 'nowrap',
|
|
64
|
+
height: '18px'
|
|
65
|
+
},
|
|
66
|
+
barValue: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '4px',
|
|
70
|
+
borderRadius: '2px',
|
|
71
|
+
backgroundColor: theme.palette.primary.main,
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
zIndex: '2'
|
|
74
|
+
},
|
|
75
|
+
arrow: {
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
zIndex: '1',
|
|
78
|
+
transform: 'rotate(-90deg) translate(0%,-50%)',
|
|
79
|
+
transition: 'transform 300ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
80
|
+
transitionProperty: 'transform color',
|
|
81
|
+
fontSize: 20,
|
|
82
|
+
cursor: 'pointer'
|
|
83
|
+
},
|
|
84
|
+
leftLabel: {
|
|
85
|
+
color: theme.palette.primary.main,
|
|
86
|
+
left: '0px',
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
fontSize: '11px',
|
|
89
|
+
alignSelf: 'flex-end'
|
|
90
|
+
},
|
|
91
|
+
rightLabel: {
|
|
92
|
+
color: '#737373',
|
|
93
|
+
right: '0px',
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
fontSize: '11px',
|
|
96
|
+
alignSelf: 'flex-end'
|
|
97
|
+
},
|
|
98
|
+
textValue: {
|
|
99
|
+
position: 'absolute',
|
|
100
|
+
zIndex: '2'
|
|
101
|
+
},
|
|
102
|
+
trackAfter: {
|
|
103
|
+
backgroundColor: 'gray',
|
|
104
|
+
opacity: 0.24
|
|
105
|
+
},
|
|
106
|
+
focused: {
|
|
107
|
+
fontSize: 24,
|
|
108
|
+
color: theme.palette.primary.dark
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* HiSlider component
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
exports.styles = styles;
|
|
118
|
+
|
|
119
|
+
var HiSlider =
|
|
120
|
+
/*#__PURE__*/
|
|
121
|
+
function (_React$Component) {
|
|
122
|
+
(0, _inherits2.default)(HiSlider, _React$Component);
|
|
123
|
+
|
|
124
|
+
function HiSlider(props) {
|
|
125
|
+
var _this;
|
|
126
|
+
|
|
127
|
+
(0, _classCallCheck2.default)(this, HiSlider);
|
|
128
|
+
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiSlider).call(this, props));
|
|
129
|
+
|
|
130
|
+
_this.handleChange = function (event) {
|
|
131
|
+
_this.props.onChange(parseFloat(event.target.value));
|
|
132
|
+
|
|
133
|
+
_this.textValueWidth = _this.textValue.offsetWidth;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
_this.handleFocus = function (isFocused) {
|
|
137
|
+
return function () {
|
|
138
|
+
_this.setState({
|
|
139
|
+
focused: isFocused
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
_this.state = {
|
|
145
|
+
focused: false
|
|
146
|
+
};
|
|
147
|
+
return _this;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Measures several components once they are mounted.
|
|
151
|
+
* If the value and a label (left or right) are hovered,
|
|
152
|
+
* we hide this label.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
(0, _createClass2.default)(HiSlider, [{
|
|
157
|
+
key: "componentDidMount",
|
|
158
|
+
value: function componentDidMount() {
|
|
159
|
+
this.leftLabelWidth = this.leftLabel.offsetWidth;
|
|
160
|
+
this.rightLabelWidth = this.rightLabel.offsetWidth;
|
|
161
|
+
this.textValueWidth = this.textValue.offsetWidth;
|
|
162
|
+
this.barContainerWidth = this.barContainer.offsetWidth;
|
|
163
|
+
|
|
164
|
+
var _this$getHovering = this.getHovering(),
|
|
165
|
+
hoveringLeft = _this$getHovering.hoveringLeft,
|
|
166
|
+
hoveringRight = _this$getHovering.hoveringRight;
|
|
167
|
+
|
|
168
|
+
if (hoveringLeft || hoveringRight) {
|
|
169
|
+
this.forceUpdate();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Calculates if the labels are hovered.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
}, {
|
|
177
|
+
key: "getHovering",
|
|
178
|
+
value: function getHovering() {
|
|
179
|
+
var ratio = (this.props.value - this.props.min) / (this.props.max - this.props.min);
|
|
180
|
+
var hoveringLeft = this.leftLabelWidth - (ratio * this.barContainerWidth - ratio * this.textValueWidth) > 0;
|
|
181
|
+
var hoveringRight = this.barContainerWidth - ratio * this.barContainerWidth - this.rightLabelWidth - (1 - ratio) * this.textValueWidth < 0;
|
|
182
|
+
return {
|
|
183
|
+
hoveringLeft: hoveringLeft,
|
|
184
|
+
hoveringRight: hoveringRight
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
key: "render",
|
|
189
|
+
value: function render() {
|
|
190
|
+
var _this2 = this;
|
|
191
|
+
|
|
192
|
+
var _this$props = this.props,
|
|
193
|
+
classes = _this$props.classes,
|
|
194
|
+
className = _this$props.className,
|
|
195
|
+
min = _this$props.min,
|
|
196
|
+
max = _this$props.max,
|
|
197
|
+
leftLabel = _this$props.leftLabel,
|
|
198
|
+
rightLabel = _this$props.rightLabel,
|
|
199
|
+
step = _this$props.step,
|
|
200
|
+
suffix = _this$props.suffix,
|
|
201
|
+
id = _this$props.id,
|
|
202
|
+
label = _this$props.label,
|
|
203
|
+
value = _this$props.value,
|
|
204
|
+
theme = _this$props.theme;
|
|
205
|
+
var focused = this.state.focused;
|
|
206
|
+
var ratio = (value - min) / (max - min);
|
|
207
|
+
var percentage = ratio * 100;
|
|
208
|
+
|
|
209
|
+
var _this$getHovering2 = this.getHovering(),
|
|
210
|
+
hoveringLeft = _this$getHovering2.hoveringLeft,
|
|
211
|
+
hoveringRight = _this$getHovering2.hoveringRight;
|
|
212
|
+
|
|
213
|
+
var barColor = focused ? theme.palette.primary.dark : theme.palette.primary.main;
|
|
214
|
+
return (// HiFormControl pour l'affichage du label
|
|
215
|
+
_react.default.createElement(_HiFormControl.default, {
|
|
216
|
+
id: id,
|
|
217
|
+
label: label,
|
|
218
|
+
className: className,
|
|
219
|
+
onFocus: this.handleFocus(true),
|
|
220
|
+
onBlur: this.handleFocus(false)
|
|
221
|
+
}, _react.default.createElement("div", {
|
|
222
|
+
className: classes.mainContainer
|
|
223
|
+
}, _react.default.createElement("div", null, min, suffix), _react.default.createElement("div", {
|
|
224
|
+
className: classes.barContainer,
|
|
225
|
+
ref: function ref(div) {
|
|
226
|
+
_this2.barContainer = div;
|
|
227
|
+
}
|
|
228
|
+
}, _react.default.createElement("div", {
|
|
229
|
+
className: classes.topContainer
|
|
230
|
+
}, !hoveringLeft && _react.default.createElement("div", {
|
|
231
|
+
className: classes.leftLabel,
|
|
232
|
+
ref: function ref(div) {
|
|
233
|
+
_this2.leftLabel = div;
|
|
234
|
+
}
|
|
235
|
+
}, leftLabel), _react.default.createElement("div", {
|
|
236
|
+
className: classes.textValue,
|
|
237
|
+
style: {
|
|
238
|
+
left: "".concat(percentage, "%"),
|
|
239
|
+
transform: "translate(-".concat(percentage, "%)")
|
|
240
|
+
},
|
|
241
|
+
ref: function ref(div) {
|
|
242
|
+
_this2.textValue = div;
|
|
243
|
+
}
|
|
244
|
+
}, value, suffix), !hoveringRight && _react.default.createElement("div", {
|
|
245
|
+
className: classes.rightLabel,
|
|
246
|
+
ref: function ref(div) {
|
|
247
|
+
_this2.rightLabel = div;
|
|
248
|
+
}
|
|
249
|
+
}, rightLabel)), _react.default.createElement("div", {
|
|
250
|
+
className: classes.barValue,
|
|
251
|
+
style: {
|
|
252
|
+
background: "linear-gradient(to right, ".concat(barColor, ", ").concat(barColor, " ").concat(percentage, "%, #E0E0E0 ").concat(percentage, "%, #E0E0E0)")
|
|
253
|
+
}
|
|
254
|
+
}), _react.default.createElement("input", {
|
|
255
|
+
type: 'range',
|
|
256
|
+
min: min,
|
|
257
|
+
max: max,
|
|
258
|
+
value: value,
|
|
259
|
+
onChange: this.handleChange,
|
|
260
|
+
className: classes.barHidden,
|
|
261
|
+
step: step
|
|
262
|
+
}), _react.default.createElement("div", {
|
|
263
|
+
className: classes.bottomContainer
|
|
264
|
+
}, _react.default.createElement(_HiIcon.default, {
|
|
265
|
+
className: (0, _classnames.default)(classes.arrow, (0, _defineProperty2.default)({}, classes.focused, focused)),
|
|
266
|
+
icon: 'play_arrow',
|
|
267
|
+
style: {
|
|
268
|
+
left: "".concat(percentage, "%"),
|
|
269
|
+
color: barColor
|
|
270
|
+
}
|
|
271
|
+
}))), _react.default.createElement("div", null, max, suffix)))
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}]);
|
|
275
|
+
return HiSlider;
|
|
276
|
+
}(_react.default.Component);
|
|
277
|
+
|
|
278
|
+
HiSlider.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
279
|
+
/**
|
|
280
|
+
* Useful to extend the style applied to components.
|
|
281
|
+
*/
|
|
282
|
+
classes: _propTypes.default.object,
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Classes CSS appliquées.
|
|
286
|
+
*/
|
|
287
|
+
className: _propTypes.default.string,
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Id de l'élément input
|
|
291
|
+
*/
|
|
292
|
+
id: _propTypes.default.string.isRequired,
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Label du champ
|
|
296
|
+
*/
|
|
297
|
+
label: _propTypes.default.string,
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The label to show on the left.
|
|
301
|
+
*/
|
|
302
|
+
leftLabel: _propTypes.default.string,
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The Maximum value for the slider.
|
|
306
|
+
*/
|
|
307
|
+
max: _propTypes.default.number.isRequired,
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The Minimum value for the slider.
|
|
311
|
+
*/
|
|
312
|
+
min: _propTypes.default.number.isRequired,
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Fonction de callback appelée lorsqu'on change la valeur du slider.
|
|
316
|
+
*/
|
|
317
|
+
onChange: _propTypes.default.func,
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* The label to show on the right
|
|
321
|
+
*/
|
|
322
|
+
rightLabel: _propTypes.default.string,
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The step between two selectable values.
|
|
326
|
+
*/
|
|
327
|
+
step: _propTypes.default.number,
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The suffix to show after each number.
|
|
331
|
+
*/
|
|
332
|
+
suffix: _propTypes.default.string,
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @ignore
|
|
336
|
+
*/
|
|
337
|
+
theme: _propTypes.default.object,
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The
|
|
341
|
+
* value of the input.
|
|
342
|
+
*/
|
|
343
|
+
value: _propTypes.default.number
|
|
344
|
+
} : {};
|
|
345
|
+
|
|
346
|
+
var _default = (0, _withStyles.default)(styles, {
|
|
347
|
+
hiComponent: true,
|
|
348
|
+
name: 'HiSlider',
|
|
349
|
+
withTheme: true
|
|
350
|
+
})(HiSlider);
|
|
351
|
+
|
|
352
|
+
exports.default = _default;
|