@hipay/hipay-material-ui 2.0.0-beta.56 → 2.0.0-beta.58
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 +117 -0
- package/HiAlertModal/HiAlertModal.js +56 -13
- package/HiColoredLabel/HiColoredLabel.js +1 -1
- package/HiDatePicker/Caption.js +8 -1
- package/HiDatePicker/HiDatePicker.js +9 -3
- package/HiDatePicker/HiDateRangePicker.js +9 -3
- package/HiDatePicker/HiDateRangeSelector.js +54 -4
- package/HiDatePicker/NavBar.js +8 -1
- package/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +123 -0
- package/HiDatePicker/Overlays/MonthPickerOverlay.js +4 -4
- package/HiDatePicker/Overlays/YearPickerOverlay.js +2 -2
- package/HiDatePicker/hiLocaleUtils.js +144 -0
- package/HiDatePicker/stylesheet.js +31 -6
- package/HiForm/HiFormControl.js +4 -4
- package/HiForm/HiInput.js +19 -7
- package/HiForm/HiUploadField.js +2 -1
- package/HiNotice/HiKPI.js +3 -3
- package/HiNotice/HiKPINotice.js +12 -9
- package/HiPin/HiPin.js +1 -1
- package/HiSelect/HiSelect.js +6 -5
- package/HiSelect/HiSuggestSelect.js +21 -2
- package/HiSelect/SelectInput.js +5 -1
- package/HiSelectNew/HiSelect.js +163 -59
- package/HiSelectNew/HiSelectInput.js +8 -1
- package/HiSelectableList/HiSelectableList.js +4 -30
- package/HiSelectableList/HiSelectableListItem.js +19 -12
- package/README.md +9 -10
- package/es/HiAlertModal/HiAlertModal.js +55 -13
- package/es/HiColoredLabel/HiColoredLabel.js +1 -1
- package/es/HiDatePicker/Caption.js +7 -1
- package/es/HiDatePicker/HiDatePicker.js +8 -3
- package/es/HiDatePicker/HiDateRangePicker.js +8 -3
- package/es/HiDatePicker/HiDateRangeSelector.js +48 -4
- package/es/HiDatePicker/NavBar.js +7 -1
- package/es/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +106 -0
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +4 -4
- package/es/HiDatePicker/Overlays/YearPickerOverlay.js +2 -2
- package/es/HiDatePicker/hiLocaleUtils.js +131 -0
- package/es/HiDatePicker/stylesheet.js +30 -6
- package/es/HiForm/HiFormControl.js +4 -4
- package/es/HiForm/HiInput.js +19 -7
- package/es/HiForm/HiUploadField.js +2 -1
- package/es/HiNotice/HiKPI.js +3 -3
- package/es/HiNotice/HiKPINotice.js +10 -9
- package/es/HiPin/HiPin.js +1 -1
- package/es/HiSelect/HiSelect.js +6 -5
- package/es/HiSelect/HiSuggestSelect.js +21 -2
- package/es/HiSelect/SelectInput.js +5 -1
- package/es/HiSelectNew/HiSelect.js +166 -56
- package/es/HiSelectNew/HiSelectInput.js +7 -1
- package/es/HiSelectableList/HiSelectableList.js +5 -25
- package/es/HiSelectableList/HiSelectableListItem.js +23 -16
- package/es/index.js +2 -1
- package/index.es.js +2 -1
- package/index.js +10 -2
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +6207 -1359
- package/umd/hipay-material-ui.production.min.js +2 -2
@@ -17,11 +17,12 @@ export const styles = theme => ({
|
|
17
17
|
const Caption = ({
|
18
18
|
classes,
|
19
19
|
date,
|
20
|
+
locale = 'en_US',
|
20
21
|
localeUtils,
|
21
22
|
onMonthClick,
|
22
23
|
onYearClick
|
23
24
|
}) => {
|
24
|
-
const months = localeUtils.getMonths();
|
25
|
+
const months = localeUtils.getMonths(locale);
|
25
26
|
return React.createElement("div", {
|
26
27
|
className: classes.caption
|
27
28
|
}, React.createElement(HiButton, {
|
@@ -44,6 +45,11 @@ Caption.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
44
45
|
*/
|
45
46
|
date: PropTypes.object.isRequired,
|
46
47
|
|
48
|
+
/**
|
49
|
+
* ReactDayPicker prop
|
50
|
+
*/
|
51
|
+
locale: PropTypes.string,
|
52
|
+
|
47
53
|
/**
|
48
54
|
* ReactDayPicker prop
|
49
55
|
*/
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import React from 'react';
|
5
5
|
import PropTypes from 'prop-types';
|
6
6
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
7
|
+
import HiLocaleUtils from './hiLocaleUtils';
|
7
8
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
8
9
|
import withStyles from '../styles/withStyles';
|
9
10
|
import Caption from './Caption';
|
@@ -216,12 +217,13 @@ class HiDatePicker extends React.Component {
|
|
216
217
|
navbarElement: props2 => React.createElement(NavBar, _extends({
|
217
218
|
showClockButton: enableTime,
|
218
219
|
onClockClick: this.handleClockClick
|
219
|
-
}, props2
|
220
|
+
}, props2, {
|
221
|
+
localeUtils: HiLocaleUtils
|
222
|
+
})),
|
220
223
|
captionElement: this.renderCaption,
|
221
224
|
classNames: classes,
|
222
225
|
disabledDays: effectiveDisabledDays,
|
223
226
|
selectedDays: typeof value === 'object' ? value : undefined,
|
224
|
-
locale,
|
225
227
|
firstDayOfWeek: 1,
|
226
228
|
fromMonth: minimumDate,
|
227
229
|
modifiers: {
|
@@ -230,7 +232,10 @@ class HiDatePicker extends React.Component {
|
|
230
232
|
},
|
231
233
|
modifiersStyles,
|
232
234
|
month: currentMonth
|
233
|
-
}, props
|
235
|
+
}, props, {
|
236
|
+
locale,
|
237
|
+
localeUtils: HiLocaleUtils
|
238
|
+
});
|
234
239
|
|
235
240
|
const inputProps = _objectSpread({}, onReset && {
|
236
241
|
onReset: this.handleReset
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import React from 'react';
|
5
5
|
import PropTypes from 'prop-types';
|
6
6
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
7
|
+
import HiLocaleUtils from './hiLocaleUtils';
|
7
8
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
8
9
|
import classNames from 'classnames';
|
9
10
|
import withStyles from '../styles/withStyles';
|
@@ -58,7 +59,7 @@ class HiDateRangePicker extends React.Component {
|
|
58
59
|
this.onDayToClick = day => {
|
59
60
|
let change = moment(day) >= moment(this.props.from);
|
60
61
|
|
61
|
-
if (change && this.props.disableFutureDays && moment(day) > moment()) {
|
62
|
+
if (change && this.props.disableFutureDays && moment(day).utc() > moment().utc().endOf('day')) {
|
62
63
|
change = false;
|
63
64
|
}
|
64
65
|
|
@@ -112,9 +113,9 @@ class HiDateRangePicker extends React.Component {
|
|
112
113
|
|
113
114
|
if (name === 'to' && comparativeDate > moment(date) || name === 'from' && comparativeDate < moment(date)) {
|
114
115
|
error = translations.to_superior_from;
|
115
|
-
} else if (date < minimumDate) {
|
116
|
+
} else if (moment(date).utc() < moment(minimumDate).utc().startOf('day')) {
|
116
117
|
error = translations.date_inferior_min_date.replace('%s', moment(minimumDate).format(format));
|
117
|
-
} else if (disableFutureDays && date > now) {
|
118
|
+
} else if (disableFutureDays && moment(date).utc() > moment(now).utc().endOf('day')) {
|
118
119
|
error = translations.date_superior_max_date.replace('%s', moment().format(format));
|
119
120
|
}
|
120
121
|
|
@@ -350,6 +351,8 @@ class HiDateRangePicker extends React.Component {
|
|
350
351
|
}, to && {
|
351
352
|
after: to
|
352
353
|
}),
|
354
|
+
locale,
|
355
|
+
localeUtils: HiLocaleUtils,
|
353
356
|
month: this.state.currentMonth,
|
354
357
|
modifiers: _objectSpread({}, modifiers)
|
355
358
|
});
|
@@ -366,6 +369,8 @@ class HiDateRangePicker extends React.Component {
|
|
366
369
|
}, from && {
|
367
370
|
before: from
|
368
371
|
}),
|
372
|
+
locale,
|
373
|
+
localeUtils: HiLocaleUtils,
|
369
374
|
month: this.state.currentMonth,
|
370
375
|
modifiers: _objectSpread({}, modifiers)
|
371
376
|
}); // From & To InputProps
|
@@ -9,6 +9,49 @@ import withStyles from '../styles/withStyles';
|
|
9
9
|
import HiSelectField from '../HiSelectNew/HiSelectField';
|
10
10
|
import HiDateRangePicker from './HiDateRangePicker';
|
11
11
|
import HiFormControl from '../HiForm/HiFormControl';
|
12
|
+
export function findSeparator(format) {
|
13
|
+
let str = '';
|
14
|
+
|
15
|
+
if (format.search('[/]') >= 0) {
|
16
|
+
str = '/';
|
17
|
+
} else if (format.search('[-]') >= 0) {
|
18
|
+
str = '-';
|
19
|
+
} else if (format.search('[.]') >= 0) {
|
20
|
+
str = '.';
|
21
|
+
}
|
22
|
+
|
23
|
+
return str;
|
24
|
+
}
|
25
|
+
export function yearAndMonth(format, date) {
|
26
|
+
const findY = el => {
|
27
|
+
return el.toUpperCase().search('Y') >= 0;
|
28
|
+
};
|
29
|
+
|
30
|
+
const findM = el => {
|
31
|
+
return el.toUpperCase().search('M') >= 0;
|
32
|
+
};
|
33
|
+
|
34
|
+
const s = findSeparator(format);
|
35
|
+
const split = format.split(s);
|
36
|
+
const indexY = split.findIndex(findY);
|
37
|
+
const indexM = split.findIndex(findM);
|
38
|
+
return indexY < indexM ? date.format(split[indexY] + s + split[indexM]) : date.format(split[indexM] + s + split[indexY]);
|
39
|
+
}
|
40
|
+
export function yearAndQuarter(format, date, t) {
|
41
|
+
const findY = el => {
|
42
|
+
return el.toUpperCase().search('Y') >= 0;
|
43
|
+
};
|
44
|
+
|
45
|
+
const findM = el => {
|
46
|
+
return el.toUpperCase().search('M') >= 0;
|
47
|
+
};
|
48
|
+
|
49
|
+
const s = findSeparator(format);
|
50
|
+
const split = format.split(s);
|
51
|
+
const indexY = split.findIndex(findY);
|
52
|
+
const indexM = split.findIndex(findM);
|
53
|
+
return indexY < indexM ? date.format(`${split[indexY]}${s}[${t.short_quarter}]Q`) : date.format(`[${t.short_quarter}]Q${s}${split[indexY]}`);
|
54
|
+
}
|
12
55
|
export function buildDateRangeOptionByKey(key, t, format) {
|
13
56
|
let from;
|
14
57
|
let label;
|
@@ -68,21 +111,21 @@ export function buildDateRangeOptionByKey(key, t, format) {
|
|
68
111
|
label = t.previous_month;
|
69
112
|
from = moment().subtract(1, 'month').startOf('month');
|
70
113
|
to = moment().subtract(1, 'month').endOf('month');
|
71
|
-
info = `${from
|
114
|
+
info = `${yearAndMonth(format, from)}, ${from.daysInMonth()} ${t.days}`;
|
72
115
|
break;
|
73
116
|
|
74
117
|
case 'cq':
|
75
118
|
label = t.current_quarter;
|
76
119
|
from = moment().startOf('quarter');
|
77
120
|
to = moment();
|
78
|
-
info = `${from
|
121
|
+
info = `${yearAndQuarter(format, from, t)}, ${from.format(format)} ${t.to_now}, ${to.diff(from, 'days') + 1} ${t.days}`;
|
79
122
|
break;
|
80
123
|
|
81
124
|
case 'pq':
|
82
125
|
label = t.previous_quarter;
|
83
126
|
from = moment().subtract(1, 'quarter').startOf('quarter');
|
84
127
|
to = moment().subtract(1, 'quarter').endOf('quarter');
|
85
|
-
info = `${from
|
128
|
+
info = `${yearAndQuarter(format, from, t)}, ${to.diff(from, 'days') + 1} ${t.days}`;
|
86
129
|
break;
|
87
130
|
|
88
131
|
case 'cy':
|
@@ -117,7 +160,7 @@ export const styles = () => ({
|
|
117
160
|
},
|
118
161
|
dateRangePicker: {
|
119
162
|
width: 'calc(100% + 8px)',
|
120
|
-
marginTop:
|
163
|
+
marginTop: 0
|
121
164
|
},
|
122
165
|
smSelect: {},
|
123
166
|
smRangePicker: {}
|
@@ -306,6 +349,7 @@ HiDateRangeSelector.defaultProps = {
|
|
306
349
|
quarter: 'Quarter',
|
307
350
|
week: 'Week',
|
308
351
|
short_week: 'W',
|
352
|
+
short_quarter: 'Q',
|
309
353
|
yearAndMonth: 'YYYY[-]MM',
|
310
354
|
yearAndQuarter: 'YYYY[-Q]Q',
|
311
355
|
year: 'Year',
|
@@ -41,6 +41,7 @@ var _ref3 = React.createElement(AccessTime, null);
|
|
41
41
|
|
42
42
|
const NavBar = ({
|
43
43
|
classes,
|
44
|
+
locale = 'en_US',
|
44
45
|
localeUtils,
|
45
46
|
nextMonth,
|
46
47
|
onClockClick,
|
@@ -49,7 +50,7 @@ const NavBar = ({
|
|
49
50
|
previousMonth,
|
50
51
|
showClockButton
|
51
52
|
}) => {
|
52
|
-
const months = localeUtils.getMonths();
|
53
|
+
const months = localeUtils.getMonths(locale);
|
53
54
|
const prev = `${months[previousMonth.getMonth()]} ${previousMonth.getFullYear()}`;
|
54
55
|
const next = `${months[nextMonth.getMonth()]} ${nextMonth.getFullYear()}`;
|
55
56
|
return React.createElement("div", {
|
@@ -74,6 +75,11 @@ NavBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
74
75
|
*/
|
75
76
|
classes: PropTypes.object,
|
76
77
|
|
78
|
+
/**
|
79
|
+
* ReactDayPicker prop
|
80
|
+
*/
|
81
|
+
locale: PropTypes.string,
|
82
|
+
|
77
83
|
/**
|
78
84
|
* ReactDayPicker prop
|
79
85
|
*/
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
3
|
+
import React from 'react';
|
4
|
+
import PropTypes from 'prop-types';
|
5
|
+
import classNames from 'classnames';
|
6
|
+
import Paper from '@material-ui/core/Paper';
|
7
|
+
import withStyles from '../../styles/withStyles';
|
8
|
+
export const styles = theme => ({
|
9
|
+
paper: {
|
10
|
+
width: '100%',
|
11
|
+
zIndex: 10
|
12
|
+
},
|
13
|
+
absolute: {
|
14
|
+
position: 'absolute'
|
15
|
+
},
|
16
|
+
relative: {
|
17
|
+
position: 'relative'
|
18
|
+
},
|
19
|
+
left: {
|
20
|
+
width: '200%',
|
21
|
+
left: 0
|
22
|
+
},
|
23
|
+
right: {
|
24
|
+
width: '200%',
|
25
|
+
left: '-100%'
|
26
|
+
},
|
27
|
+
overlay: _objectSpread({
|
28
|
+
padding: 0,
|
29
|
+
height: 325,
|
30
|
+
textAlign: 'center'
|
31
|
+
}, theme.typography.body2, {
|
32
|
+
fontWeight: theme.typography.fontWeightRegular
|
33
|
+
}),
|
34
|
+
header: _objectSpread({
|
35
|
+
display: 'block',
|
36
|
+
height: 40,
|
37
|
+
textAlign: 'center',
|
38
|
+
padding: '10px 0'
|
39
|
+
}, theme.typography.body1, {
|
40
|
+
color: theme.palette.neutral.main,
|
41
|
+
borderBottom: '1px solid',
|
42
|
+
borderBottomColor: theme.palette.divider
|
43
|
+
}),
|
44
|
+
body: {
|
45
|
+
height: 285,
|
46
|
+
width: 224,
|
47
|
+
margin: 'auto'
|
48
|
+
}
|
49
|
+
});
|
50
|
+
|
51
|
+
const CustomOverlayLayoutWithoutFooter = (_ref) => {
|
52
|
+
let {
|
53
|
+
classes,
|
54
|
+
children,
|
55
|
+
headerElement,
|
56
|
+
footerElement,
|
57
|
+
absoluteElement,
|
58
|
+
side,
|
59
|
+
staticPosition
|
60
|
+
} = _ref,
|
61
|
+
props = _objectWithoutProperties(_ref, ["classes", "children", "headerElement", "footerElement", "absoluteElement", "side", "staticPosition"]);
|
62
|
+
|
63
|
+
const paperClass = classNames(classes.paper, {
|
64
|
+
[classes.left]: side === 'from',
|
65
|
+
[classes.right]: side === 'to',
|
66
|
+
[classes.absolute]: staticPosition !== true,
|
67
|
+
[classes.relative]: staticPosition === true
|
68
|
+
});
|
69
|
+
|
70
|
+
const paperProps = _objectSpread({}, props);
|
71
|
+
|
72
|
+
return (// eslint-disable-next-line react/jsx-handler-names
|
73
|
+
React.createElement(Paper, {
|
74
|
+
className: paperClass,
|
75
|
+
onBlur: paperProps.onBlur,
|
76
|
+
onFocus: paperProps.onFocus
|
77
|
+
}, React.createElement("div", {
|
78
|
+
className: classes.overlay
|
79
|
+
}, React.createElement("div", {
|
80
|
+
className: classes.header
|
81
|
+
}, headerElement), React.createElement("div", {
|
82
|
+
className: classes.body
|
83
|
+
}, children), absoluteElement))
|
84
|
+
);
|
85
|
+
};
|
86
|
+
|
87
|
+
CustomOverlayLayoutWithoutFooter.propTypes = process.env.NODE_ENV !== "production" ? {
|
88
|
+
absoluteElement: PropTypes.any,
|
89
|
+
children: PropTypes.any,
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Useful to extend the style applied to components.
|
93
|
+
*/
|
94
|
+
classes: PropTypes.object,
|
95
|
+
footerElement: PropTypes.any,
|
96
|
+
headerElement: PropTypes.any,
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Définit comment construire le Paper dans le cas d'un double input
|
100
|
+
*/
|
101
|
+
side: PropTypes.string,
|
102
|
+
staticPosition: PropTypes.bool
|
103
|
+
} : {};
|
104
|
+
export default withStyles(styles, {
|
105
|
+
name: 'HmuiCustomOverlayLayoutWithoutFooter'
|
106
|
+
})(CustomOverlayLayoutWithoutFooter);
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
3
|
import React from 'react';
|
4
4
|
import PropTypes from 'prop-types';
|
5
|
-
import
|
5
|
+
import CustomOverlayLayoutWithoutFooter from './CustomOverlayLayoutWithoutFooter';
|
6
6
|
import ListPicker from '../ListPicker';
|
7
7
|
|
8
8
|
class MonthPickerOverlay extends React.Component {
|
@@ -10,7 +10,7 @@ class MonthPickerOverlay extends React.Component {
|
|
10
10
|
super();
|
11
11
|
this.months = [];
|
12
12
|
this.handleMonthClick = this.handleMonthClick.bind(this);
|
13
|
-
this.months = props.localeUtils ? props.localeUtils.getMonths() : props.children.props.localeUtils.getMonths();
|
13
|
+
this.months = props.localeUtils ? props.localeUtils.getMonths(props.children.props.locale) : props.children.props.localeUtils.getMonths(props.children.props.locale);
|
14
14
|
}
|
15
15
|
|
16
16
|
handleMonthClick(month) {
|
@@ -32,8 +32,8 @@ class MonthPickerOverlay extends React.Component {
|
|
32
32
|
props = _objectWithoutProperties(_this$props, ["value", "translations"]);
|
33
33
|
|
34
34
|
const now = new Date();
|
35
|
-
const currentMonth = props.localeUtils ? props.localeUtils.getMonths()[now.getMonth()] : props.children.props.localeUtils.getMonths()[now.getMonth()];
|
36
|
-
return React.createElement(
|
35
|
+
const currentMonth = props.localeUtils ? props.localeUtils.getMonths(props.children.props.locale)[now.getMonth()] : props.children.props.localeUtils.getMonths(props.children.props.locale)[now.getMonth()];
|
36
|
+
return React.createElement(CustomOverlayLayoutWithoutFooter, _extends({
|
37
37
|
headerElement: translations.month
|
38
38
|
}, props), React.createElement(ListPicker, {
|
39
39
|
itemList: this.months,
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
3
|
import React from 'react';
|
4
4
|
import PropTypes from 'prop-types';
|
5
|
-
import
|
5
|
+
import CustomOverlayLayoutWithoutFooter from './CustomOverlayLayoutWithoutFooter';
|
6
6
|
import ListPicker from '../ListPicker';
|
7
7
|
|
8
8
|
class YearPickerOverlay extends React.Component {
|
@@ -42,7 +42,7 @@ class YearPickerOverlay extends React.Component {
|
|
42
42
|
} = _this$props,
|
43
43
|
props = _objectWithoutProperties(_this$props, ["value", "translations"]);
|
44
44
|
|
45
|
-
return React.createElement(
|
45
|
+
return React.createElement(CustomOverlayLayoutWithoutFooter, _extends({
|
46
46
|
headerElement: translations.year
|
47
47
|
}, props), React.createElement(ListPicker, {
|
48
48
|
itemList: this.years,
|
@@ -0,0 +1,131 @@
|
|
1
|
+
const WEEKDAYS_LONG = {
|
2
|
+
en_US: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
3
|
+
fr_FR: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']
|
4
|
+
};
|
5
|
+
const WEEKDAYS_SHORT = {
|
6
|
+
en_US: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
7
|
+
fr_FR: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa']
|
8
|
+
};
|
9
|
+
const MONTHS = {
|
10
|
+
en_US: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
11
|
+
fr_FR: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
|
12
|
+
};
|
13
|
+
const FIRST_DAY = {
|
14
|
+
en_US: 0,
|
15
|
+
fr_FR: 1 // Use Monday as first day of the week
|
16
|
+
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* Format Date as day
|
20
|
+
*
|
21
|
+
* @param Date d
|
22
|
+
* @param string locale
|
23
|
+
*
|
24
|
+
* @returns string
|
25
|
+
*/
|
26
|
+
|
27
|
+
function formatDay(d, locale = 'en_US') {
|
28
|
+
const loc = this.formatLocale(locale);
|
29
|
+
return `${WEEKDAYS_LONG[loc][d.getDay()]}, ${d.getDate()} ${MONTHS[loc][d.getMonth()]} ${d.getFullYear()}`;
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Format Date as month title
|
33
|
+
*
|
34
|
+
* @param Date d
|
35
|
+
* @param string locale
|
36
|
+
*
|
37
|
+
* @returns string
|
38
|
+
*/
|
39
|
+
|
40
|
+
|
41
|
+
function formatMonthTitle(d, locale = 'en_US') {
|
42
|
+
const loc = this.formatLocale(locale);
|
43
|
+
return `${MONTHS[loc][d.getMonth()]} ${d.getFullYear()}`;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* Get the short version of a week day
|
47
|
+
*
|
48
|
+
* @param int i
|
49
|
+
* @param string locale
|
50
|
+
*
|
51
|
+
* @returns string
|
52
|
+
*/
|
53
|
+
|
54
|
+
|
55
|
+
function formatWeekdayShort(i, locale = 'en_US') {
|
56
|
+
const loc = this.formatLocale(locale);
|
57
|
+
return WEEKDAYS_SHORT[loc][i];
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Get the long version of a week day
|
61
|
+
*
|
62
|
+
* @param int i
|
63
|
+
* @param string locale
|
64
|
+
*
|
65
|
+
* @returns string
|
66
|
+
*/
|
67
|
+
|
68
|
+
|
69
|
+
function formatWeekdayLong(i, locale = 'en_US') {
|
70
|
+
const loc = this.formatLocale(locale);
|
71
|
+
return WEEKDAYS_LONG[loc][i];
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Get first day of the week
|
75
|
+
* @param string locale
|
76
|
+
*
|
77
|
+
* @returns integer
|
78
|
+
*/
|
79
|
+
|
80
|
+
|
81
|
+
function getFirstDayOfWeek(locale = 'en_US') {
|
82
|
+
const loc = this.formatLocale(locale);
|
83
|
+
return FIRST_DAY[loc];
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Get List of Months
|
87
|
+
*
|
88
|
+
* @param string locale
|
89
|
+
*
|
90
|
+
* @returns array
|
91
|
+
*/
|
92
|
+
|
93
|
+
|
94
|
+
function getMonths(locale = 'en_US') {
|
95
|
+
const loc = this.formatLocale(locale);
|
96
|
+
return MONTHS[loc];
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Format locale
|
100
|
+
*
|
101
|
+
* @param string locale
|
102
|
+
*
|
103
|
+
* @return string
|
104
|
+
*/
|
105
|
+
|
106
|
+
|
107
|
+
function formatLocale(locale) {
|
108
|
+
let loc = locale.split('-');
|
109
|
+
|
110
|
+
if (loc.length !== 2) {
|
111
|
+
loc = locale.split('_');
|
112
|
+
|
113
|
+
if (loc.length !== 2) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
loc[1] = loc[1].toUpperCase();
|
119
|
+
return loc.join('_');
|
120
|
+
}
|
121
|
+
|
122
|
+
const HiLocaleUtils = {
|
123
|
+
formatDay,
|
124
|
+
formatMonthTitle,
|
125
|
+
formatWeekdayShort,
|
126
|
+
formatWeekdayLong,
|
127
|
+
getFirstDayOfWeek,
|
128
|
+
getMonths,
|
129
|
+
formatLocale
|
130
|
+
};
|
131
|
+
export default HiLocaleUtils;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
2
|
+
import { fade } from '../styles/colorManipulator';
|
2
3
|
export default (theme => ({
|
3
4
|
root: {
|
4
5
|
position: 'relative',
|
@@ -140,31 +141,54 @@ export default (theme => ({
|
|
140
141
|
footer: {
|
141
142
|
marginTop: 12,
|
142
143
|
borderTop: '1px solid',
|
143
|
-
borderTopColor: theme.palette.divider
|
144
|
+
borderTopColor: theme.palette.divider,
|
145
|
+
padding: '5px',
|
146
|
+
width: '100%'
|
144
147
|
},
|
145
148
|
// The today button (only with todayButton prop)
|
146
149
|
todayButton: _objectSpread({
|
147
|
-
|
150
|
+
display: 'table',
|
151
|
+
minWidth: 230,
|
152
|
+
margin: '0 auto',
|
148
153
|
border: 'none',
|
149
154
|
backgroundImage: 'none',
|
150
155
|
backgroundColor: 'transparent',
|
151
156
|
boxShadow: 'none',
|
152
157
|
cursor: 'pointer',
|
153
|
-
height:
|
158
|
+
height: 30
|
154
159
|
}, theme.typography.body2, {
|
155
160
|
color: theme.palette.neutral.main,
|
156
161
|
fontWeight: theme.typography.fontWeightMedium,
|
157
|
-
textTransform: 'uppercase'
|
162
|
+
textTransform: 'uppercase',
|
163
|
+
'&:hover': {
|
164
|
+
backgroundColor: fade(theme.palette.neutral.dark, theme.palette.action.hoverOpacity),
|
165
|
+
// Reset on touch devices, it doesn't add specificity
|
166
|
+
'@media (hover: none)': {
|
167
|
+
backgroundColor: 'transparent'
|
168
|
+
}
|
169
|
+
},
|
170
|
+
borderRadius: 4
|
158
171
|
}),
|
159
172
|
|
160
173
|
/* default modifiers */
|
161
174
|
// Added to the day's cell for the current day
|
162
175
|
today: {
|
163
176
|
// color: theme.palette.primary.light,
|
164
|
-
|
177
|
+
position: 'relative',
|
165
178
|
borderRadius: '50%',
|
166
179
|
color: `${theme.palette.neutral.dark} !important`,
|
167
|
-
fontWeight: theme.typography.fontWeightMedium
|
180
|
+
fontWeight: theme.typography.fontWeightMedium,
|
181
|
+
'&:before': {
|
182
|
+
content: '""',
|
183
|
+
position: 'absolute',
|
184
|
+
top: 0,
|
185
|
+
left: 0,
|
186
|
+
display: 'inline-block',
|
187
|
+
width: '100%',
|
188
|
+
height: '100%',
|
189
|
+
borderRadius: '50%',
|
190
|
+
boxShadow: `inset 0 0 0 2px ${theme.palette.neutral.main}`
|
191
|
+
}
|
168
192
|
},
|
169
193
|
// Added to the day's cell outside the current month
|
170
194
|
outside: {
|
@@ -27,6 +27,8 @@ export const styles = theme => ({
|
|
27
27
|
cursor: 'pointer',
|
28
28
|
zIndex: 1,
|
29
29
|
top: '-5px',
|
30
|
+
height: 24,
|
31
|
+
width: 24,
|
30
32
|
'&$iconButtonError': {
|
31
33
|
color: theme.palette.negative.main
|
32
34
|
},
|
@@ -197,16 +199,14 @@ class HiFormControl extends React.PureComponent {
|
|
197
199
|
focused: !disabled && (focused || hovered)
|
198
200
|
}, InputLabelProps), error && errorText && React.createElement(HiIconButton, {
|
199
201
|
className: classNames(classes.iconButton, classes.iconButtonError),
|
200
|
-
onClick: this.handleHelperClick
|
201
|
-
onKeyDown: this.handleKeyDown
|
202
|
+
onClick: this.handleHelperClick
|
202
203
|
}, React.createElement(Warning, {
|
203
204
|
className: classNames(classes.icon)
|
204
205
|
})), helperIcon && helperText && !error && React.createElement(HiIconButton, {
|
205
206
|
className: classNames(classes.iconButton, classes.iconButtonInfo, {
|
206
207
|
[classes.iconButtonInfoActive]: helperOpen
|
207
208
|
}),
|
208
|
-
onClick: this.handleHelperClick
|
209
|
-
onKeyDown: this.handleKeyDown
|
209
|
+
onClick: this.handleHelperClick
|
210
210
|
}, React.createElement(Info, {
|
211
211
|
className: classNames(classes.icon)
|
212
212
|
}))), React.createElement("div", {
|
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
|
},
|
@@ -177,10 +177,15 @@ class HiInput extends React.PureComponent {
|
|
177
177
|
// Si on click sur un élément de HiInput, on garde le focus
|
178
178
|
// Par exemple sur l'icone reset
|
179
179
|
if (event.relatedTarget && this.overlayNode && this.overlayNode.contains(event.relatedTarget)) {
|
180
|
-
|
180
|
+
// If blur came from erase icon => stay focused and don't call onBlur props
|
181
|
+
if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
|
182
|
+
event.preventDefault();
|
183
|
+
event.stopPropagation();
|
184
|
+
} else if (this.endAdornmentNode.contains(event.relatedTarget) && this.props.onBlur) {
|
181
185
|
this.props.onBlur(event);
|
182
186
|
}
|
183
187
|
|
188
|
+
event.preventDefault();
|
184
189
|
event.stopPropagation();
|
185
190
|
} else {
|
186
191
|
this.setState({
|
@@ -201,9 +206,13 @@ class HiInput extends React.PureComponent {
|
|
201
206
|
this.setState({
|
202
207
|
focused: true
|
203
208
|
});
|
204
|
-
}
|
209
|
+
} // If focus came from erase icon => stay focused and don't call onFocus props
|
210
|
+
|
205
211
|
|
206
|
-
if (this.
|
212
|
+
if (this.eraseIconNode && this.eraseIconNode.contains(event.relatedTarget)) {
|
213
|
+
event.preventDefault();
|
214
|
+
event.stopPropagation();
|
215
|
+
} else if (this.props.onFocus) {
|
207
216
|
this.props.onFocus(event);
|
208
217
|
}
|
209
218
|
}
|
@@ -306,7 +315,10 @@ class HiInput extends React.PureComponent {
|
|
306
315
|
label: classes.eraseButtonLabel
|
307
316
|
},
|
308
317
|
onClick: this.handleReset,
|
309
|
-
onBlur: this.handleBlur
|
318
|
+
onBlur: this.handleBlur,
|
319
|
+
buttonRef: el => {
|
320
|
+
this.eraseIconNode = el;
|
321
|
+
}
|
310
322
|
}, _ref);
|
311
323
|
let endAdornment = endAdornmentProps;
|
312
324
|
|