@hipay/hipay-material-ui 2.0.0-beta.60 → 2.0.0-beta.61
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +60 -0
- package/HiDatePicker/HiDatePicker.js +37 -12
- package/HiDatePicker/HiDateRangePicker.js +71 -57
- package/HiDatePicker/HiDateRangeSelector.js +33 -19
- package/HiDatePicker/stylesheet.js +32 -17
- package/HiSelectNew/HiDynamicSelect.js +3 -3
- package/HiSelectNew/HiNestedSelect.js +9 -9
- package/HiSelectNew/HiNestedSelectContent.js +9 -9
- package/HiSelectNew/HiSelect.js +7 -7
- package/HiSelectNew/HiSelectContent.js +7 -7
- package/HiSelectableList/HiSelectableList.js +9 -0
- package/es/HiDatePicker/HiDatePicker.js +30 -10
- package/es/HiDatePicker/HiDateRangePicker.js +38 -21
- package/es/HiDatePicker/HiDateRangeSelector.js +23 -12
- package/es/HiDatePicker/stylesheet.js +32 -17
- package/es/HiSelectableList/HiSelectableList.js +9 -0
- package/es/styles/createPalette.js +1 -1
- package/es/utils/helpers.js +9 -1
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -3
- package/styles/createPalette.js +1 -1
- package/umd/hipay-material-ui.development.js +41769 -43732
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +9 -1
@@ -43,12 +43,12 @@ var _helpers = require("../utils/helpers");
|
|
43
43
|
*/
|
44
44
|
function getRecursiveFinalItemIdList(itemList) {
|
45
45
|
var finalItemIdList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
46
|
-
return
|
46
|
+
return (0, _toConsumableArray2.default)(finalItemIdList).concat((0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
|
47
47
|
if (item.children) {
|
48
48
|
return getRecursiveFinalItemIdList(item.children, memo);
|
49
49
|
}
|
50
50
|
|
51
|
-
return
|
51
|
+
return (0, _toConsumableArray2.default)(memo).concat([item.id]);
|
52
52
|
}, [])));
|
53
53
|
}
|
54
54
|
/**
|
@@ -124,7 +124,7 @@ function buildFilteredItemList(itemList) {
|
|
124
124
|
}
|
125
125
|
|
126
126
|
return {
|
127
|
-
l:
|
127
|
+
l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({}, item, disabledParent && {
|
128
128
|
disabled: true,
|
129
129
|
hideCheckbox: true // don't display checkbox on disabled parent
|
130
130
|
|
@@ -143,7 +143,7 @@ function buildFilteredItemList(itemList) {
|
|
143
143
|
|
144
144
|
var itemSelected = selectedItemIdList.includes(item.id);
|
145
145
|
return {
|
146
|
-
l:
|
146
|
+
l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({
|
147
147
|
displayed: itemVisible || visibleParent
|
148
148
|
}, item)]),
|
149
149
|
s: itemSelected && memoSelected,
|
@@ -223,9 +223,9 @@ function (_React$PureComponent) {
|
|
223
223
|
}), item);
|
224
224
|
} else {
|
225
225
|
// select parent > add each selectable child without duplicates.
|
226
|
-
onChange(event,
|
226
|
+
onChange(event, (0, _toConsumableArray2.default)(value.filter(function (vid) {
|
227
227
|
return !parentSelectableItemIdList.includes(vid);
|
228
|
-
}))
|
228
|
+
})).concat((0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
|
229
229
|
}
|
230
230
|
} else if (value.includes(item.id)) {
|
231
231
|
// unselect item
|
@@ -233,7 +233,7 @@ function (_React$PureComponent) {
|
|
233
233
|
return id !== item.id;
|
234
234
|
}), item);
|
235
235
|
} else {
|
236
|
-
onChange(event,
|
236
|
+
onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
|
237
237
|
}
|
238
238
|
};
|
239
239
|
|
@@ -271,14 +271,14 @@ function (_React$PureComponent) {
|
|
271
271
|
centered: true,
|
272
272
|
hideCheckbox: true,
|
273
273
|
label: translations.no_result_match
|
274
|
-
}]) :
|
274
|
+
}]) : (0, _toConsumableArray2.default)(loading ? [{
|
275
275
|
id: '_loading',
|
276
276
|
type: 'loader',
|
277
277
|
disabled: true,
|
278
278
|
centered: true,
|
279
279
|
hideCheckbox: true,
|
280
280
|
label: 'loading'
|
281
|
-
}] : [])
|
281
|
+
}] : []).concat((0, _toConsumableArray2.default)(hasAll ? [{
|
282
282
|
id: '_all',
|
283
283
|
iconAll: iconAll,
|
284
284
|
label: translations.all,
|
package/HiSelectNew/HiSelect.js
CHANGED
@@ -148,22 +148,22 @@ function (_React$PureComponent) {
|
|
148
148
|
var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
149
149
|
var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
150
150
|
// build item list
|
151
|
-
var itemList =
|
151
|
+
var itemList = (0, _toConsumableArray2.default)(loading ? [{
|
152
152
|
id: '_loading',
|
153
153
|
type: 'loader',
|
154
154
|
disabled: true,
|
155
155
|
centered: true,
|
156
156
|
hideCheckbox: true,
|
157
157
|
label: 'loading'
|
158
|
-
}] : [])
|
158
|
+
}] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
|
159
159
|
return _this.props.filterFunc(item, search);
|
160
|
-
})) :
|
160
|
+
})) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
|
161
161
|
id: '_all',
|
162
162
|
label: _this.props.translations.all
|
163
163
|
}, _this.props.iconAll && {
|
164
164
|
type: 'icon',
|
165
165
|
icon: _this.props.iconAll
|
166
|
-
})] : [])
|
166
|
+
})] : []).concat((0, _toConsumableArray2.default)(options))));
|
167
167
|
return {
|
168
168
|
itemList: itemList,
|
169
169
|
inputValue: _this.buildInputValue(options, value, loading)
|
@@ -462,7 +462,7 @@ function (_React$PureComponent) {
|
|
462
462
|
return id !== item.id;
|
463
463
|
}), item);
|
464
464
|
} else {
|
465
|
-
onChange(event,
|
465
|
+
onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
|
466
466
|
}
|
467
467
|
};
|
468
468
|
|
@@ -488,13 +488,13 @@ function (_React$PureComponent) {
|
|
488
488
|
});
|
489
489
|
} else {
|
490
490
|
_this.setState({
|
491
|
-
suggestions:
|
491
|
+
suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
|
492
492
|
id: '_all',
|
493
493
|
label: translations.all
|
494
494
|
}, iconAll && {
|
495
495
|
type: 'icon',
|
496
496
|
icon: iconAll
|
497
|
-
})] : [])
|
497
|
+
})] : []).concat((0, _toConsumableArray2.default)(suggestions))
|
498
498
|
});
|
499
499
|
}
|
500
500
|
};
|
@@ -179,7 +179,7 @@ function (_React$PureComponent) {
|
|
179
179
|
return id !== item.id;
|
180
180
|
}), item);
|
181
181
|
} else {
|
182
|
-
onChange(event,
|
182
|
+
onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
|
183
183
|
}
|
184
184
|
};
|
185
185
|
|
@@ -209,13 +209,13 @@ function (_React$PureComponent) {
|
|
209
209
|
});
|
210
210
|
} else {
|
211
211
|
_this.setState({
|
212
|
-
suggestions:
|
212
|
+
suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
|
213
213
|
id: '_all',
|
214
214
|
label: translations.all
|
215
215
|
}, iconAll && {
|
216
216
|
type: 'icon',
|
217
217
|
icon: iconAll
|
218
|
-
})] : [])
|
218
|
+
})] : []).concat((0, _toConsumableArray2.default)(suggestions))
|
219
219
|
});
|
220
220
|
}
|
221
221
|
};
|
@@ -251,22 +251,22 @@ function (_React$PureComponent) {
|
|
251
251
|
var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
252
252
|
var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
253
253
|
// build item list
|
254
|
-
var itemList =
|
254
|
+
var itemList = (0, _toConsumableArray2.default)(loading ? [{
|
255
255
|
id: '_loading',
|
256
256
|
type: 'loader',
|
257
257
|
disabled: true,
|
258
258
|
centered: true,
|
259
259
|
hideCheckbox: true,
|
260
260
|
label: 'loading'
|
261
|
-
}] : [])
|
261
|
+
}] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
|
262
262
|
return item.label && _this.props.filterFunc(item, search);
|
263
|
-
})) :
|
263
|
+
})) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
|
264
264
|
id: '_all',
|
265
265
|
label: _this.props.translations.all
|
266
266
|
}, _this.props.iconAll && {
|
267
267
|
type: 'icon',
|
268
268
|
icon: _this.props.iconAll
|
269
|
-
})] : [])
|
269
|
+
})] : []).concat((0, _toConsumableArray2.default)(options))));
|
270
270
|
return {
|
271
271
|
itemList: itemList
|
272
272
|
};
|
@@ -112,6 +112,10 @@ function (_React$PureComponent) {
|
|
112
112
|
};
|
113
113
|
|
114
114
|
_this.compareItem = function (a, b) {
|
115
|
+
if (_this.props.comparItemFunc) {
|
116
|
+
return _this.props.comparItemFunc(a, b);
|
117
|
+
}
|
118
|
+
|
115
119
|
if (a.label === undefined || b.label === undefined) {
|
116
120
|
return 0;
|
117
121
|
}
|
@@ -184,6 +188,11 @@ HiSelectableList.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
184
188
|
*/
|
185
189
|
classes: _propTypes.default.object,
|
186
190
|
|
191
|
+
/**
|
192
|
+
* Fonction de comparaison utilisée pour les tris
|
193
|
+
*/
|
194
|
+
comparItemFunc: _propTypes.default.func,
|
195
|
+
|
187
196
|
/**
|
188
197
|
* Désactive la listes
|
189
198
|
*/
|
@@ -3,6 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
4
4
|
import React from 'react';
|
5
5
|
import PropTypes from 'prop-types';
|
6
|
+
import moment from 'moment-timezone';
|
6
7
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
7
8
|
import HiLocaleUtils from './hiLocaleUtils';
|
8
9
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
@@ -20,9 +21,18 @@ import styles from './stylesheet';
|
|
20
21
|
class HiDatePicker extends React.Component {
|
21
22
|
constructor(props) {
|
22
23
|
super();
|
24
|
+
|
25
|
+
this.handleKeyDown = name => event => {
|
26
|
+
if (event.key === 'Escape' && !event.shiftKey) {
|
27
|
+
this.datePickerInput.hideDayPicker();
|
28
|
+
event.stopPropagation();
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
const today = moment().tz(props.timezoneName);
|
23
33
|
this.state = {
|
24
34
|
openedPanel: 'calendar',
|
25
|
-
currentMonth: props.value ? props.value : new Date()
|
35
|
+
currentMonth: props.value ? props.value : new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
26
36
|
}; // this.formatDate = this.formatDate.bind(this);
|
27
37
|
|
28
38
|
this.handleCalendarClick = this.handleCalendarClick.bind(this);
|
@@ -46,15 +56,16 @@ class HiDatePicker extends React.Component {
|
|
46
56
|
clearTimeout(this.timeout);
|
47
57
|
}
|
48
58
|
|
49
|
-
handleReset() {
|
50
|
-
this.handleCurrentMonthChange(new Date());
|
51
|
-
this.props.onReset();
|
52
|
-
}
|
53
|
-
|
54
59
|
handleInputChange(event) {
|
55
60
|
this.props.onChange(event.target.value);
|
56
61
|
}
|
57
62
|
|
63
|
+
handleReset() {
|
64
|
+
const today = moment().tz(this.props.timezoneName);
|
65
|
+
this.handleCurrentMonthChange(new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds()));
|
66
|
+
this.props.onReset();
|
67
|
+
}
|
68
|
+
|
58
69
|
handleDayChange(day, modifiers) {
|
59
70
|
if (day) {
|
60
71
|
if (modifiers.selected) {
|
@@ -198,11 +209,12 @@ class HiDatePicker extends React.Component {
|
|
198
209
|
const {
|
199
210
|
currentMonth
|
200
211
|
} = this.state;
|
212
|
+
const today = moment().tz(this.props.timezoneName);
|
201
213
|
|
202
214
|
const effectiveDisabledDays = _objectSpread({}, disablePastDays && {
|
203
|
-
before: new Date()
|
215
|
+
before: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
204
216
|
}, disableFutureDays && {
|
205
|
-
after: new Date()
|
217
|
+
after: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
206
218
|
}, disabledDays);
|
207
219
|
|
208
220
|
const modifiersStyles = {
|
@@ -229,7 +241,8 @@ class HiDatePicker extends React.Component {
|
|
229
241
|
fromMonth: minimumDate,
|
230
242
|
modifiers: {
|
231
243
|
disabled: effectiveDisabledDays,
|
232
|
-
selected: value
|
244
|
+
selected: value,
|
245
|
+
[classes.currentDay]: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
233
246
|
},
|
234
247
|
modifiersStyles,
|
235
248
|
month: currentMonth
|
@@ -248,7 +261,8 @@ class HiDatePicker extends React.Component {
|
|
248
261
|
});
|
249
262
|
|
250
263
|
return React.createElement("div", {
|
251
|
-
className: classes.root
|
264
|
+
className: classes.root,
|
265
|
+
onKeyDown: this.handleKeyDown()
|
252
266
|
}, React.createElement(DayPickerInput, {
|
253
267
|
ref: el => {
|
254
268
|
this.datePickerInput = el;
|
@@ -279,6 +293,7 @@ HiDatePicker.defaultProps = {
|
|
279
293
|
locale: 'fr-FR',
|
280
294
|
minimumDate: new Date(2013, 4, 1),
|
281
295
|
// by default 1 May 2013
|
296
|
+
timezoneName: 'Europe/Paris',
|
282
297
|
translations: {
|
283
298
|
today: 'today'
|
284
299
|
}
|
@@ -347,6 +362,11 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
347
362
|
*/
|
348
363
|
onSubmit: PropTypes.func,
|
349
364
|
|
365
|
+
/**
|
366
|
+
* Timezone de l'utilisateur
|
367
|
+
*/
|
368
|
+
timezoneName: PropTypes.string,
|
369
|
+
|
350
370
|
/**
|
351
371
|
* Traductions
|
352
372
|
*/
|
@@ -3,6 +3,7 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
4
4
|
import React from 'react';
|
5
5
|
import PropTypes from 'prop-types';
|
6
|
+
import moment from 'moment-timezone';
|
6
7
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
7
8
|
import HiLocaleUtils from './hiLocaleUtils';
|
8
9
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
@@ -17,7 +18,6 @@ import NavBar from './NavBar';
|
|
17
18
|
import Weekday from './Weekday';
|
18
19
|
import { HiTextField } from '../HiForm';
|
19
20
|
import styles from './stylesheet';
|
20
|
-
import moment from 'moment';
|
21
21
|
import HiFormControl from '../HiForm/HiFormControl';
|
22
22
|
|
23
23
|
class HiDateRangePicker extends React.Component {
|
@@ -58,8 +58,10 @@ class HiDateRangePicker extends React.Component {
|
|
58
58
|
|
59
59
|
this.onDayToClick = day => {
|
60
60
|
let change = moment(day) >= moment(this.props.from);
|
61
|
+
const today = moment().tz(this.props.timezoneName);
|
62
|
+
const todayDate = new Date(today.year(), today.month(), today.date(), 23, 59, 59);
|
61
63
|
|
62
|
-
if (change &&
|
64
|
+
if (change && day > todayDate) {
|
63
65
|
change = false;
|
64
66
|
}
|
65
67
|
|
@@ -85,11 +87,13 @@ class HiDateRangePicker extends React.Component {
|
|
85
87
|
|
86
88
|
this.handleChange = (name, day) => {
|
87
89
|
const {
|
88
|
-
translations
|
90
|
+
translations,
|
91
|
+
timezoneName
|
89
92
|
} = this.props;
|
90
93
|
let date;
|
91
94
|
let error;
|
92
|
-
const
|
95
|
+
const today = moment().tz(timezoneName);
|
96
|
+
const now = new Date(today.year(), today.month(), today.date(), 23, 59, 59);
|
93
97
|
const {
|
94
98
|
minimumDate,
|
95
99
|
disableFutureDays,
|
@@ -115,8 +119,8 @@ class HiDateRangePicker extends React.Component {
|
|
115
119
|
error = translations.to_superior_from;
|
116
120
|
} else if (moment(date).utc() < moment(minimumDate).utc().startOf('day')) {
|
117
121
|
error = translations.date_inferior_min_date.replace('%s', moment(minimumDate).format(format));
|
118
|
-
} else if (disableFutureDays &&
|
119
|
-
error = translations.date_superior_max_date.replace('%s', moment().format(format));
|
122
|
+
} else if (disableFutureDays && date > now) {
|
123
|
+
error = translations.date_superior_max_date.replace('%s', moment().tz(timezoneName).format(format));
|
120
124
|
}
|
121
125
|
|
122
126
|
if (!this.props.enableTime) {
|
@@ -165,15 +169,11 @@ class HiDateRangePicker extends React.Component {
|
|
165
169
|
|
166
170
|
this.handleReset = name => {
|
167
171
|
this.handleChange(name, undefined);
|
168
|
-
this.setState(prevState => ({
|
169
|
-
keyFrom: prevState.keyFrom === 1 ? 2 : 1,
|
170
|
-
keyTo: prevState.keyTo === 1 ? 2 : 1
|
171
|
-
}));
|
172
172
|
};
|
173
173
|
|
174
174
|
this.handleKeyDown = name => event => {
|
175
175
|
if (event.key === 'Tab' && !event.shiftKey) {
|
176
|
-
|
176
|
+
const nodeName = document.activeElement.nodeName;
|
177
177
|
|
178
178
|
if (this.props[name] && nodeName === 'INPUT' && document.activeElement.nextSibling.children.length > 0) {
|
179
179
|
document.activeElement.nextSibling.focus();
|
@@ -191,6 +191,14 @@ class HiDateRangePicker extends React.Component {
|
|
191
191
|
document.activeElement.blur();
|
192
192
|
}, 1);
|
193
193
|
}
|
194
|
+
} else if (event.key === 'Escape' && !event.shiftKey) {
|
195
|
+
if (name === 'from') {
|
196
|
+
this.fromInput.hideDayPicker();
|
197
|
+
} else if (name === 'to') {
|
198
|
+
this.toInput.hideDayPicker();
|
199
|
+
}
|
200
|
+
|
201
|
+
event.stopPropagation();
|
194
202
|
}
|
195
203
|
};
|
196
204
|
|
@@ -276,12 +284,12 @@ class HiDateRangePicker extends React.Component {
|
|
276
284
|
}, yearPickerProps, propsOverlay));
|
277
285
|
};
|
278
286
|
|
287
|
+
const _today = moment().tz(this.props.timezoneName);
|
288
|
+
|
279
289
|
this.state = {
|
280
|
-
currentMonth: new Date(),
|
290
|
+
currentMonth: new Date(_today.year(), _today.month(), _today.date()),
|
281
291
|
focusedInput: '',
|
282
|
-
openedPanel: 'calendar'
|
283
|
-
keyFrom: 1,
|
284
|
-
keyTo: 1
|
292
|
+
openedPanel: 'calendar'
|
285
293
|
};
|
286
294
|
}
|
287
295
|
|
@@ -313,14 +321,17 @@ class HiDateRangePicker extends React.Component {
|
|
313
321
|
errorText,
|
314
322
|
hasSelector,
|
315
323
|
helperIcon,
|
316
|
-
helperText
|
324
|
+
helperText,
|
325
|
+
timezoneName
|
317
326
|
} = _this$props,
|
318
|
-
props = _objectWithoutProperties(_this$props, ["classes", "disabled", "disabledDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "fromError", "minimumDate", "onReset", "to", "toError", "translations", "id", "staticPosition", "errorText", "hasSelector", "helperIcon", "helperText"]);
|
327
|
+
props = _objectWithoutProperties(_this$props, ["classes", "disabled", "disabledDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "fromError", "minimumDate", "onReset", "to", "toError", "translations", "id", "staticPosition", "errorText", "hasSelector", "helperIcon", "helperText", "timezoneName"]);
|
319
328
|
|
320
|
-
const
|
329
|
+
const today = moment().tz(timezoneName);
|
330
|
+
const now = new Date(today.year(), today.month(), today.date(), 23, 59, 59, 999);
|
321
331
|
const modifiers = {
|
322
332
|
start: from,
|
323
|
-
end: to
|
333
|
+
end: to,
|
334
|
+
[classes.currentDay]: new Date(today.year(), today.month(), today.date())
|
324
335
|
};
|
325
336
|
const modifiersStyles = {
|
326
337
|
start: {
|
@@ -440,7 +451,7 @@ class HiDateRangePicker extends React.Component {
|
|
440
451
|
onFocus: () => this.handleDayPickerFocus('from'),
|
441
452
|
onKeyDown: this.handleKeyDown('from')
|
442
453
|
}, React.createElement("div", null, React.createElement(DayPickerInput, {
|
443
|
-
key:
|
454
|
+
key: '1',
|
444
455
|
ref: el => {
|
445
456
|
this.fromInput = el;
|
446
457
|
},
|
@@ -461,7 +472,7 @@ class HiDateRangePicker extends React.Component {
|
|
461
472
|
onBlur: () => this.handleDayPickerBlur('to'),
|
462
473
|
onKeyDown: this.handleKeyDown('to')
|
463
474
|
}, React.createElement(DayPickerInput, {
|
464
|
-
key:
|
475
|
+
key: '1',
|
465
476
|
ref: el => {
|
466
477
|
this.toInput = el;
|
467
478
|
},
|
@@ -505,6 +516,7 @@ HiDateRangePicker.defaultProps = {
|
|
505
516
|
locale: 'fr-FR',
|
506
517
|
minimumDate: new Date(2013, 4, 1),
|
507
518
|
// by default 1 May 2013
|
519
|
+
timezoneName: 'Europe/Paris',
|
508
520
|
translations: {
|
509
521
|
today: 'today',
|
510
522
|
hour: 'Hour',
|
@@ -636,6 +648,11 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
636
648
|
*/
|
637
649
|
staticPosition: PropTypes.bool,
|
638
650
|
|
651
|
+
/**
|
652
|
+
* Timezone de l'utilisateur
|
653
|
+
*/
|
654
|
+
timezoneName: PropTypes.string,
|
655
|
+
|
639
656
|
/**
|
640
657
|
* Date de fin sélectionnée
|
641
658
|
*/
|
@@ -187,18 +187,7 @@ class HiDateRangeSelector extends React.Component {
|
|
187
187
|
[name]: value,
|
188
188
|
key: prevState.key === 1 ? 2 : 1
|
189
189
|
}));
|
190
|
-
|
191
|
-
|
192
|
-
if (selectedOption) {
|
193
|
-
this.props.onChange('from', new Date(selectedOption.from.format('YYYY-MM-DD HH:mm:ss')));
|
194
|
-
this.props.onChange('to', new Date(selectedOption.to.format('YYYY-MM-DD HH:mm:ss')));
|
195
|
-
this.props.onChange('fromError', false);
|
196
|
-
this.props.onChange('toError', false);
|
197
|
-
}
|
198
|
-
|
199
|
-
if (this.props.returnSelectValue === true) {
|
200
|
-
this.props.onChange('period', value);
|
201
|
-
}
|
190
|
+
this.updateDates(value);
|
202
191
|
};
|
203
192
|
|
204
193
|
this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format, props.timezoneName));
|
@@ -226,10 +215,32 @@ class HiDateRangeSelector extends React.Component {
|
|
226
215
|
}
|
227
216
|
}
|
228
217
|
|
218
|
+
componentDidUpdate(prevProps) {
|
219
|
+
if (prevProps.timezoneName !== this.props.timezoneName) {
|
220
|
+
this.options = this.props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, this.props.translations, this.props.format, this.props.timezoneName));
|
221
|
+
this.updateDates(this.state.selectedPreset);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
229
225
|
componentWillUnmount() {
|
230
226
|
clearTimeout(this.timeout); // TODO : supprimer ?
|
231
227
|
}
|
232
228
|
|
229
|
+
updateDates(value) {
|
230
|
+
const selectedOption = this.options.find(option => option.id === value);
|
231
|
+
|
232
|
+
if (selectedOption) {
|
233
|
+
this.props.onChange('from', new Date(selectedOption.from.format('YYYY-MM-DD HH:mm:ss')));
|
234
|
+
this.props.onChange('to', new Date(selectedOption.to.format('YYYY-MM-DD HH:mm:ss')));
|
235
|
+
this.props.onChange('fromError', false);
|
236
|
+
this.props.onChange('toError', false);
|
237
|
+
}
|
238
|
+
|
239
|
+
if (this.props.returnSelectValue === true) {
|
240
|
+
this.props.onChange('period', value);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
233
244
|
render() {
|
234
245
|
const _this$props = this.props,
|
235
246
|
{
|
@@ -172,23 +172,22 @@ export default (theme => ({
|
|
172
172
|
|
173
173
|
/* default modifiers */
|
174
174
|
// Added to the day's cell for the current day
|
175
|
-
today: {
|
176
|
-
//
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
'
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
}
|
175
|
+
today: {// color: theme.palette.primary.light,
|
176
|
+
// position: 'relative',
|
177
|
+
// borderRadius: '50%',
|
178
|
+
// color: `${theme.palette.neutral.dark} !important`,
|
179
|
+
// fontWeight: theme.typography.fontWeightMedium,
|
180
|
+
// '&:before': {
|
181
|
+
// content: '""',
|
182
|
+
// position: 'absolute',
|
183
|
+
// top: 0,
|
184
|
+
// left: 0,
|
185
|
+
// display: 'inline-block',
|
186
|
+
// width: '100%',
|
187
|
+
// height: '100%',
|
188
|
+
// borderRadius: '50%',
|
189
|
+
// boxShadow: `inset 0 0 0 2px ${theme.palette.neutral.main}`,
|
190
|
+
// },
|
192
191
|
},
|
193
192
|
// Added to the day's cell outside the current month
|
194
193
|
outside: {
|
@@ -216,5 +215,21 @@ export default (theme => ({
|
|
216
215
|
color: theme.palette.primary.contrastText,
|
217
216
|
borderRadius: '0%',
|
218
217
|
border: 'none'
|
218
|
+
},
|
219
|
+
currentDay: {
|
220
|
+
position: 'relative',
|
221
|
+
color: `${theme.palette.neutral.dark} !important`,
|
222
|
+
fontWeight: theme.typography.fontWeightMedium,
|
223
|
+
'&:before': {
|
224
|
+
content: '""',
|
225
|
+
position: 'absolute',
|
226
|
+
top: 0,
|
227
|
+
left: 0,
|
228
|
+
display: 'inline-block',
|
229
|
+
width: '100%',
|
230
|
+
height: '100%',
|
231
|
+
borderRadius: '50%',
|
232
|
+
boxShadow: `inset 0 0 0 2px ${theme.palette.neutral.main}`
|
233
|
+
}
|
219
234
|
}
|
220
235
|
}));
|
@@ -61,6 +61,10 @@ class HiSelectableList extends React.PureComponent {
|
|
61
61
|
};
|
62
62
|
|
63
63
|
this.compareItem = (a, b) => {
|
64
|
+
if (this.props.comparItemFunc) {
|
65
|
+
return this.props.comparItemFunc(a, b);
|
66
|
+
}
|
67
|
+
|
64
68
|
if (a.label === undefined || b.label === undefined) {
|
65
69
|
return 0;
|
66
70
|
}
|
@@ -123,6 +127,11 @@ HiSelectableList.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
123
127
|
*/
|
124
128
|
classes: PropTypes.object,
|
125
129
|
|
130
|
+
/**
|
131
|
+
* Fonction de comparaison utilisée pour les tris
|
132
|
+
*/
|
133
|
+
comparItemFunc: PropTypes.func,
|
134
|
+
|
126
135
|
/**
|
127
136
|
* Désactive la listes
|
128
137
|
*/
|
@@ -30,7 +30,7 @@ export const light = {
|
|
30
30
|
hint: 'rgba(0, 0, 0, 0.38)'
|
31
31
|
},
|
32
32
|
// The color used to divide different elements.
|
33
|
-
divider: '
|
33
|
+
divider: '#D9D9DB',
|
34
34
|
// The background colors used to style the surfaces.
|
35
35
|
// Consistency between these values is important.
|
36
36
|
background: {
|
package/es/utils/helpers.js
CHANGED
@@ -250,7 +250,7 @@ export function getNextItemSelectable(node, direction) {
|
|
250
250
|
*/
|
251
251
|
|
252
252
|
export function foldAccents(toFold) {
|
253
|
-
return toFold.replace(/([àáâãäå])|([ç])|([èéêë])|([ìíîï])|([ñ])|([òóôõöø])|([ß])|([ùúûü])|([ÿ])|([æ])|([œ])/g, (str, a, c, e, i, n, o, s, u, y, ae, oe) => {
|
253
|
+
return toFold.replace(/([àáâãäå])|([ç])|([èéêë])|([ìíîï])|([ñ])|([òóôõöø])|([ß])|([ùúûü])|([ÿ])|([æ])|([œ])|([+])|([\\])|([\[])|([\]])|([\(])|([\)])|([?])|([*])/g, (str, a, c, e, i, n, o, s, u, y, ae, oe, plus, backSlash, lc, rc, lp, rp, interogation, star) => {
|
254
254
|
if (a) return 'a';
|
255
255
|
if (c) return 'c';
|
256
256
|
if (e) return 'e';
|
@@ -262,6 +262,14 @@ export function foldAccents(toFold) {
|
|
262
262
|
if (y) return 'y';
|
263
263
|
if (ae) return 'ae';
|
264
264
|
if (oe) return 'oe';
|
265
|
+
if (plus) return '\\+';
|
266
|
+
if (backSlash) return '\\\\';
|
267
|
+
if (lc) return '\\[';
|
268
|
+
if (rc) return '\\]';
|
269
|
+
if (lp) return '\\(';
|
270
|
+
if (rp) return '\\)';
|
271
|
+
if (interogation) return '\\?';
|
272
|
+
if (star) return '\\*';
|
265
273
|
return str;
|
266
274
|
});
|
267
275
|
}
|
package/index.es.js
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hipay/hipay-material-ui",
|
3
|
-
"private": false,
|
4
3
|
"author": "HiPay PSYCHE Team",
|
5
|
-
"version": "2.0.0-beta.
|
4
|
+
"version": "2.0.0-beta.61",
|
6
5
|
"description": "React components that implement Google's Material Design.",
|
7
6
|
"keywords": [
|
8
7
|
"react",
|
@@ -76,4 +75,4 @@
|
|
76
75
|
},
|
77
76
|
"main": "./index.js",
|
78
77
|
"module": "./index.es.js"
|
79
|
-
}
|
78
|
+
}
|