@hipay/hipay-material-ui 2.0.0-beta.36 → 2.0.0-beta.37
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/HiAppBar/HiAppBar.js +0 -2
- package/HiCell/CellAddress.js +140 -0
- package/HiCell/CellDate.js +140 -0
- package/HiCell/CellIcon.js +122 -0
- package/HiCell/CellImage.js +132 -0
- package/HiCell/CellNumeric.js +122 -0
- package/HiCell/CellPinToAction.js +92 -0
- package/HiCell/CellRate.js +184 -0
- package/HiCell/CellSentinel.js +179 -0
- package/HiCell/CellText.js +250 -0
- package/HiCell/index.js +71 -0
- package/HiCheckbox/HiCheckbox.js +2 -2
- package/HiDatePicker/Caption.js +0 -1
- package/HiDatePicker/HiDatePicker.js +1 -1
- package/HiDatePicker/HiDateRangePicker.js +756 -0
- package/HiDatePicker/HiDateRangeSelector.js +495 -0
- package/HiDatePicker/ListPicker.js +0 -1
- package/HiDatePicker/ListPicker.spec.js +1 -2
- package/HiDatePicker/NavBar.js +2 -2
- package/HiDatePicker/NavBar.spec.js +4 -5
- package/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
- package/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
- package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
- package/HiDatePicker/Overlays/Overlay.js +0 -1
- package/HiDatePicker/Overlays/Overlay.spec.js +0 -5
- package/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
- package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
- package/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
- package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
- package/HiDatePicker/Weekday.js +0 -1
- package/HiDatePicker/stylesheet.js +7 -3
- package/HiForm/HiFormControl.js +23 -3
- package/HiForm/HiInput.js +2 -2
- package/HiSelect/HiSelect.js +1 -1
- package/HiSelect/HiSuggestSelect.js +8 -8
- package/HiSelectableList/HiSelectableList.js +3 -1
- package/HiSelectableList/HiSelectableListItem.js +14 -11
- package/es/HiAppBar/HiAppBar.js +0 -2
- package/es/HiCell/CellAddress.js +97 -0
- package/es/HiCell/CellDate.js +94 -0
- package/es/HiCell/CellIcon.js +83 -0
- package/es/HiCell/CellImage.js +91 -0
- package/es/HiCell/CellNumeric.js +80 -0
- package/es/HiCell/CellPinToAction.js +53 -0
- package/es/HiCell/CellRate.js +142 -0
- package/es/HiCell/CellSentinel.js +140 -0
- package/es/HiCell/CellText.js +198 -0
- package/es/HiCell/index.js +8 -0
- package/es/HiCheckbox/HiCheckbox.js +2 -2
- package/es/HiDatePicker/Caption.js +0 -1
- package/es/HiDatePicker/HiDatePicker.js +1 -1
- package/es/HiDatePicker/HiDateRangePicker.js +661 -0
- package/es/HiDatePicker/HiDateRangeSelector.js +432 -0
- package/es/HiDatePicker/ListPicker.js +0 -1
- package/es/HiDatePicker/ListPicker.spec.js +1 -2
- package/es/HiDatePicker/NavBar.js +2 -2
- package/es/HiDatePicker/NavBar.spec.js +4 -5
- package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
- package/es/HiDatePicker/Overlays/Overlay.js +0 -1
- package/es/HiDatePicker/Overlays/Overlay.spec.js +0 -3
- package/es/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
- package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
- package/es/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
- package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
- package/es/HiDatePicker/Overlays/index.js +0 -1
- package/es/HiDatePicker/Weekday.js +0 -1
- package/es/HiDatePicker/stylesheet.js +7 -3
- package/es/HiForm/HiFormControl.js +22 -3
- package/es/HiForm/HiInput.js +2 -2
- package/es/HiSelect/HiSelect.js +1 -1
- package/es/HiSelect/HiSuggestSelect.js +8 -8
- package/es/HiSelectableList/HiSelectableList.js +3 -1
- package/es/HiSelectableList/HiSelectableListItem.js +14 -11
- package/es/index.js +2 -1
- package/es/styles/createPalette.js +2 -1
- package/es/utils/helpers.js +117 -0
- package/index.es.js +3 -2
- package/index.js +1 -1
- package/package.json +1 -1
- package/styles/createPalette.js +1 -1
- package/umd/hipay-material-ui.development.js +39 -14
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +134 -0
@@ -0,0 +1,432 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
// @inheritedComponent HiDateRangePicker
|
4
|
+
import React from 'react';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import moment from 'moment';
|
7
|
+
import { findDOMNode } from 'react-dom';
|
8
|
+
import { Grid } from '@material-ui/core';
|
9
|
+
import withStyles from '../styles/withStyles';
|
10
|
+
import { HiSelectField } from '../HiSelect';
|
11
|
+
import HiDateRangePicker from './HiDateRangePicker';
|
12
|
+
export function buildDateRangeOptionByKey(key, t, format) {
|
13
|
+
let from;
|
14
|
+
let label;
|
15
|
+
let info;
|
16
|
+
let to;
|
17
|
+
let type;
|
18
|
+
moment.updateLocale('en', {
|
19
|
+
week: {
|
20
|
+
dow: 1
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
24
|
+
switch (key) {
|
25
|
+
case 'custom':
|
26
|
+
label = t.custom_period;
|
27
|
+
type = 'primary-highlight';
|
28
|
+
break;
|
29
|
+
|
30
|
+
case 'cd':
|
31
|
+
label = t.today;
|
32
|
+
from = moment().startOf('day');
|
33
|
+
to = moment().endOf('day');
|
34
|
+
info = `${from.format(format)}`;
|
35
|
+
break;
|
36
|
+
|
37
|
+
case 'pd':
|
38
|
+
label = t.yesterday;
|
39
|
+
from = moment().subtract(1, 'day').startOf('day');
|
40
|
+
to = moment().subtract(1, 'day').endOf('day');
|
41
|
+
info = `${from.format(format)}`;
|
42
|
+
break;
|
43
|
+
|
44
|
+
case 'cw':
|
45
|
+
label = t.current_week;
|
46
|
+
from = moment().startOf('week');
|
47
|
+
to = moment();
|
48
|
+
info = `${t.short_week}${from.format('w')}, \n ${from.format(format)} ${t.to_now}`;
|
49
|
+
break;
|
50
|
+
|
51
|
+
case 'pw':
|
52
|
+
label = t.previous_week;
|
53
|
+
from = moment().subtract(1, 'week').startOf('week');
|
54
|
+
to = moment().subtract(1, 'week').endOf('week');
|
55
|
+
info = `${t.short_week}${from.format('w')}, ${from.format(format)} ${t.to} ${to.format(format)}`;
|
56
|
+
break;
|
57
|
+
|
58
|
+
case 'cm':
|
59
|
+
label = t.current_month;
|
60
|
+
from = moment().startOf('month');
|
61
|
+
to = moment();
|
62
|
+
info = `${from.format(format)} ${t.to_now}, ${to.diff(from, 'days')} ${t.days}`;
|
63
|
+
break;
|
64
|
+
|
65
|
+
case 'pm':
|
66
|
+
label = t.previous_month;
|
67
|
+
from = moment().subtract(1, 'month').startOf('month');
|
68
|
+
to = moment().subtract(1, 'month').endOf('month');
|
69
|
+
info = `${from.format('YYYY-MM')}, ${to.diff(from, 'days')} ${t.days}`;
|
70
|
+
break;
|
71
|
+
|
72
|
+
case 'cq':
|
73
|
+
label = t.current_quarter;
|
74
|
+
from = moment().startOf('quarter');
|
75
|
+
to = moment();
|
76
|
+
info = `${from.format(format)} ${t.to_now}, ${to.diff(from, 'days')} ${t.days}`;
|
77
|
+
break;
|
78
|
+
|
79
|
+
case 'pq':
|
80
|
+
label = t.previous_quarter;
|
81
|
+
from = moment().subtract(1, 'quarter').startOf('quarter');
|
82
|
+
to = moment().subtract(1, 'quarter').endOf('quarter');
|
83
|
+
info = `${from.format('YYYY')}-${t.short_quarter}${from.format('Q')}, ${to.diff(from, 'days')} ${t.days}`;
|
84
|
+
break;
|
85
|
+
|
86
|
+
case 'cy':
|
87
|
+
label = t.current_year;
|
88
|
+
from = moment().startOf('year');
|
89
|
+
to = moment();
|
90
|
+
info = `${from.format(format)} ${t.to_now}, ${to.diff(from, 'days')} ${t.days}`;
|
91
|
+
break;
|
92
|
+
|
93
|
+
default:
|
94
|
+
break;
|
95
|
+
}
|
96
|
+
|
97
|
+
return {
|
98
|
+
id: key,
|
99
|
+
from,
|
100
|
+
info,
|
101
|
+
label,
|
102
|
+
to,
|
103
|
+
type
|
104
|
+
};
|
105
|
+
}
|
106
|
+
export const styles = theme => ({
|
107
|
+
root: {
|
108
|
+
maxWidth: 500,
|
109
|
+
marginLeft: -4,
|
110
|
+
alignItems: 'flex-start'
|
111
|
+
},
|
112
|
+
dateSelect: {
|
113
|
+
paddingTop: 1,
|
114
|
+
marginTop: 1
|
115
|
+
},
|
116
|
+
dateRangePicker: {
|
117
|
+
width: 'calc(100% + 8px)'
|
118
|
+
},
|
119
|
+
smSelect: {},
|
120
|
+
smRangePicker: {}
|
121
|
+
});
|
122
|
+
|
123
|
+
class HiDateRangeSelector extends React.Component {
|
124
|
+
constructor(props) {
|
125
|
+
super();
|
126
|
+
this.options = [];
|
127
|
+
|
128
|
+
this.handleSelectChange = name => (event, value) => {
|
129
|
+
this.setState({
|
130
|
+
[name]: value
|
131
|
+
});
|
132
|
+
|
133
|
+
if (value !== 'custom') {
|
134
|
+
const selectedOption = this.options.find(option => option.id === value);
|
135
|
+
|
136
|
+
if (selectedOption) {
|
137
|
+
this.props.onChange('from', selectedOption.from.toDate());
|
138
|
+
this.props.onChange('to', selectedOption.to.toDate());
|
139
|
+
}
|
140
|
+
} else {
|
141
|
+
this.setState({
|
142
|
+
defaultFrom: undefined,
|
143
|
+
defaultTo: undefined
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
147
|
+
if (this.props.returnSelectValue === true) {
|
148
|
+
this.props.onChange('period', value);
|
149
|
+
}
|
150
|
+
};
|
151
|
+
|
152
|
+
this.handleReset = this.handleReset.bind(this);
|
153
|
+
this.handleSelectChange = this.handleSelectChange.bind(this);
|
154
|
+
this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format));
|
155
|
+
let from;
|
156
|
+
let to;
|
157
|
+
|
158
|
+
if (props.defaultPreset !== 'custom') {
|
159
|
+
const selectedOption = this.options.find(option => option.id === props.defaultPreset);
|
160
|
+
|
161
|
+
if (selectedOption) {
|
162
|
+
from = selectedOption.from.toDate();
|
163
|
+
to = selectedOption.to.toDate();
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
this.state = {
|
168
|
+
selectedPreset: props.defaultPreset,
|
169
|
+
containerWidth: 0,
|
170
|
+
defaultFrom: from,
|
171
|
+
defaultTo: to
|
172
|
+
};
|
173
|
+
}
|
174
|
+
|
175
|
+
static getDerivedStateFromProps(props, state) {
|
176
|
+
if (props.defaultPreset && props.returnSelectValue) {
|
177
|
+
return {
|
178
|
+
selectedPreset: props.defaultPreset
|
179
|
+
};
|
180
|
+
}
|
181
|
+
|
182
|
+
return null;
|
183
|
+
}
|
184
|
+
|
185
|
+
componentDidMount() {
|
186
|
+
if (this.container) {
|
187
|
+
this.setState({
|
188
|
+
containerWidth: findDOMNode(this.container).clientWidth
|
189
|
+
});
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
componentWillUnmount() {
|
194
|
+
clearTimeout(this.timeout); // TODO : supprimer ?
|
195
|
+
}
|
196
|
+
|
197
|
+
handleReset(name) {
|
198
|
+
this.props.onChange(name, undefined);
|
199
|
+
}
|
200
|
+
|
201
|
+
render() {
|
202
|
+
const _this$props = this.props,
|
203
|
+
{
|
204
|
+
disabled,
|
205
|
+
enableTime,
|
206
|
+
error,
|
207
|
+
errorText,
|
208
|
+
helperIcon,
|
209
|
+
helperText,
|
210
|
+
idRange,
|
211
|
+
idSelect,
|
212
|
+
label,
|
213
|
+
from,
|
214
|
+
onChange,
|
215
|
+
required,
|
216
|
+
to,
|
217
|
+
translations,
|
218
|
+
classes,
|
219
|
+
selectProps,
|
220
|
+
staticPosition
|
221
|
+
} = _this$props,
|
222
|
+
props = _objectWithoutProperties(_this$props, ["disabled", "enableTime", "error", "errorText", "helperIcon", "helperText", "idRange", "idSelect", "label", "from", "onChange", "required", "to", "translations", "classes", "selectProps", "staticPosition"]);
|
223
|
+
|
224
|
+
const {
|
225
|
+
defaultFrom,
|
226
|
+
defaultTo,
|
227
|
+
selectedPreset
|
228
|
+
} = this.state;
|
229
|
+
return React.createElement(Grid, {
|
230
|
+
container: true,
|
231
|
+
spacing: 8,
|
232
|
+
className: classes.root,
|
233
|
+
ref: container => {
|
234
|
+
this.container = container;
|
235
|
+
}
|
236
|
+
}, React.createElement(Grid, {
|
237
|
+
item: true,
|
238
|
+
xs: 12,
|
239
|
+
sm: 4,
|
240
|
+
classes: {
|
241
|
+
'grid-sm-4': classes.smSelect
|
242
|
+
}
|
243
|
+
}, React.createElement(HiSelectField, _extends({
|
244
|
+
disabled: disabled,
|
245
|
+
error: error,
|
246
|
+
errorText: errorText,
|
247
|
+
helperIcon: helperIcon,
|
248
|
+
helperText: helperText,
|
249
|
+
id: idSelect,
|
250
|
+
label: label,
|
251
|
+
name: 'selectedPreset',
|
252
|
+
options: this.options,
|
253
|
+
onChange: this.handleSelectChange('selectedPreset'),
|
254
|
+
required: required,
|
255
|
+
translations: translations,
|
256
|
+
value: selectedPreset,
|
257
|
+
containerWidth: this.state.containerWidth,
|
258
|
+
classes: {
|
259
|
+
root: classes.dateSelect
|
260
|
+
},
|
261
|
+
staticPosition: staticPosition
|
262
|
+
}, selectProps))), React.createElement(Grid, {
|
263
|
+
item: true,
|
264
|
+
xs: 12,
|
265
|
+
sm: 8,
|
266
|
+
classes: {
|
267
|
+
'grid-sm-8': classes.smRangePicker
|
268
|
+
}
|
269
|
+
}, React.createElement(HiDateRangePicker, _extends({
|
270
|
+
classes: {
|
271
|
+
root: classes.dateRangePicker
|
272
|
+
},
|
273
|
+
id: idRange,
|
274
|
+
from: from || defaultFrom,
|
275
|
+
to: to || defaultTo,
|
276
|
+
enableTime: enableTime,
|
277
|
+
onChange: onChange,
|
278
|
+
onReset: this.handleReset,
|
279
|
+
disabled: disabled || selectedPreset !== 'custom',
|
280
|
+
translations: translations,
|
281
|
+
staticPosition: staticPosition
|
282
|
+
}, props))));
|
283
|
+
}
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
HiDateRangeSelector.defaultProps = {
|
288
|
+
availableOptionKeys: ['cd', 'pd', 'cw', 'pw', 'cm', 'pm', 'cq', 'pq', 'cy', 'custom'],
|
289
|
+
defaultPreset: 'cd',
|
290
|
+
enableTime: false,
|
291
|
+
returnSelectValue: false,
|
292
|
+
staticPosition: false,
|
293
|
+
locale: 'fr-FR',
|
294
|
+
format: 'YYYY-DD-MM',
|
295
|
+
translations: {
|
296
|
+
today: 'Today',
|
297
|
+
hour: 'Hour',
|
298
|
+
minute: 'Minute',
|
299
|
+
month: 'Month',
|
300
|
+
quarter: 'Quarter',
|
301
|
+
week: 'Week',
|
302
|
+
short_week: 'W',
|
303
|
+
short_quarter: 'Q',
|
304
|
+
year: 'Year',
|
305
|
+
days: 'days',
|
306
|
+
custom_period: 'Custom Period',
|
307
|
+
yesterday: 'Yesterday',
|
308
|
+
to: 'to',
|
309
|
+
to_now: 'to now',
|
310
|
+
current_week: 'Current Week',
|
311
|
+
previous_week: 'Previous Week',
|
312
|
+
current_month: 'Current Month',
|
313
|
+
previous_month: 'Previous Month',
|
314
|
+
current_quarter: 'Current Quarter',
|
315
|
+
previous_quarter: 'Previous Quarter',
|
316
|
+
current_year: 'Current Year'
|
317
|
+
}
|
318
|
+
};
|
319
|
+
HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
|
320
|
+
/**
|
321
|
+
* Liste des ids des options disponibles
|
322
|
+
*/
|
323
|
+
availableOptionKeys: PropTypes.array,
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Useful to extend the style applied to components.
|
327
|
+
*/
|
328
|
+
classes: PropTypes.object,
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Valeur du select par default
|
332
|
+
*/
|
333
|
+
defaultPreset: PropTypes.string,
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Si `true`, l'input sera inactif.
|
337
|
+
*/
|
338
|
+
disabled: PropTypes.bool,
|
339
|
+
|
340
|
+
/**
|
341
|
+
* Ajoute la gestion de l'heure
|
342
|
+
*/
|
343
|
+
enableTime: PropTypes.bool,
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Si `true`, le champs sera en erreur.
|
347
|
+
*/
|
348
|
+
error: PropTypes.bool,
|
349
|
+
|
350
|
+
/**
|
351
|
+
* Texte de l'erreur
|
352
|
+
*/
|
353
|
+
errorText: PropTypes.string,
|
354
|
+
|
355
|
+
/**
|
356
|
+
* Format de date utilisé
|
357
|
+
*/
|
358
|
+
format: PropTypes.string,
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Date de début sélectionnée
|
362
|
+
*/
|
363
|
+
from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
364
|
+
|
365
|
+
/**
|
366
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
367
|
+
*/
|
368
|
+
helperIcon: PropTypes.bool,
|
369
|
+
|
370
|
+
/**
|
371
|
+
* Texte de l'aide
|
372
|
+
*/
|
373
|
+
helperText: PropTypes.string,
|
374
|
+
|
375
|
+
/**
|
376
|
+
* Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
|
377
|
+
*/
|
378
|
+
idRange: PropTypes.string.isRequired,
|
379
|
+
|
380
|
+
/**
|
381
|
+
* id du champs select
|
382
|
+
*/
|
383
|
+
idSelect: PropTypes.string.isRequired,
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Label du champs
|
387
|
+
*/
|
388
|
+
label: PropTypes.string,
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Locale utilisée
|
392
|
+
*/
|
393
|
+
locale: PropTypes.string,
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Callback à la sélection d'une date
|
397
|
+
*/
|
398
|
+
onChange: PropTypes.func.isRequired,
|
399
|
+
|
400
|
+
/**
|
401
|
+
* true si champs obligatoire
|
402
|
+
*/
|
403
|
+
required: PropTypes.bool,
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Retourne la valeur du select de la période au change du select
|
407
|
+
*/
|
408
|
+
returnSelectValue: PropTypes.bool.isRequired,
|
409
|
+
|
410
|
+
/**
|
411
|
+
* Props passées au HiSelectField
|
412
|
+
*/
|
413
|
+
selectProps: PropTypes.object,
|
414
|
+
|
415
|
+
/**
|
416
|
+
* Si true, le calendrier sera dans une div static plutot que dans une popper absolute
|
417
|
+
*/
|
418
|
+
staticPosition: PropTypes.bool,
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Date de fin sélectionnée
|
422
|
+
*/
|
423
|
+
to: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Traductions
|
427
|
+
*/
|
428
|
+
translations: PropTypes.object
|
429
|
+
} : {};
|
430
|
+
export default withStyles(styles, {
|
431
|
+
name: 'HmuiHiDateRangeSelector'
|
432
|
+
})(HiDateRangeSelector);
|
@@ -1,8 +1,7 @@
|
|
1
|
-
// @flow
|
2
1
|
import React from 'react';
|
3
2
|
import { assert } from 'chai';
|
4
3
|
import { spy } from 'sinon';
|
5
|
-
import { MenuList, MenuItem } from 'material-ui/Menu';
|
4
|
+
import { MenuList, MenuItem } from '@material-ui/core/Menu';
|
6
5
|
import { createShallow, createMount } from '../test-utils/index';
|
7
6
|
import ListPicker from './ListPicker';
|
8
7
|
describe('<ListPicker />', () => {
|
@@ -1,4 +1,3 @@
|
|
1
|
-
// @flow weak
|
2
1
|
import React from 'react';
|
3
2
|
import PropTypes from 'prop-types';
|
4
3
|
import classNames from 'classnames';
|
@@ -113,5 +112,6 @@ NavBar.defaultProps = {
|
|
113
112
|
showClockButton: false
|
114
113
|
};
|
115
114
|
export default withStyles(styles, {
|
116
|
-
|
115
|
+
hiComponent: true,
|
116
|
+
name: 'HmuiNavBar'
|
117
117
|
})(NavBar);
|
@@ -1,12 +1,11 @@
|
|
1
|
-
// @flow
|
2
1
|
import React from 'react';
|
3
2
|
import { assert } from 'chai';
|
4
3
|
import { spy } from 'sinon';
|
5
4
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
6
|
-
import IconButton from 'material-ui/IconButton';
|
5
|
+
import IconButton from '@material-ui/core/IconButton';
|
7
6
|
import { createShallow } from '../test-utils/index';
|
8
|
-
import
|
9
|
-
describe('<
|
7
|
+
import NavBar from './NavBar';
|
8
|
+
describe('<NavBar />', () => {
|
10
9
|
let shallow;
|
11
10
|
before(() => {
|
12
11
|
shallow = createShallow({
|
@@ -19,7 +18,7 @@ describe('<Navbar />', () => {
|
|
19
18
|
const handlerClockClick = spy();
|
20
19
|
const nextMonth = new Date(2018, 3, 1);
|
21
20
|
const prevMonth = new Date(2018, 1, 1);
|
22
|
-
const wrapper = shallow(React.createElement(
|
21
|
+
const wrapper = shallow(React.createElement(NavBar, {
|
23
22
|
nextMonth: nextMonth,
|
24
23
|
previousMonth: prevMonth,
|
25
24
|
onNextClick: handlerNextClick,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
3
|
-
// @flow weak
|
4
3
|
import React from 'react';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import classNames from 'classnames';
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
// @flow weak
|
4
3
|
import React from 'react';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import CustomOverlayLayout from './CustomOverlayLayout';
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
// @flow weak
|
4
3
|
import React from 'react';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import classNames from 'classnames';
|
@@ -1,8 +1,5 @@
|
|
1
|
-
// @flow
|
2
1
|
import React from 'react';
|
3
2
|
import { assert } from 'chai';
|
4
|
-
import { spy } from 'sinon';
|
5
|
-
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
6
3
|
import { createShallow, getClasses } from '../../test-utils/index';
|
7
4
|
import Overlay from './Overlay';
|
8
5
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
4
|
-
// @flow weak
|
5
4
|
import React from 'react';
|
6
5
|
import PropTypes from 'prop-types';
|
7
6
|
import IconButton from '@material-ui/core/IconButton';
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
// @flow weak
|
4
3
|
import React from 'react';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import CustomOverlayLayout from './CustomOverlayLayout';
|
@@ -69,7 +69,6 @@ export default (theme => ({
|
|
69
69
|
// The month's main table
|
70
70
|
month: {
|
71
71
|
display: 'table',
|
72
|
-
borderCollapse: 'collapse',
|
73
72
|
borderSpacing: 0,
|
74
73
|
userSelect: 'none' // margin: '0 1rem',
|
75
74
|
// marginTop: '1rem',
|
@@ -161,7 +160,10 @@ export default (theme => ({
|
|
161
160
|
/* default modifiers */
|
162
161
|
// Added to the day's cell for the current day
|
163
162
|
today: {
|
164
|
-
color: theme.palette.primary.light,
|
163
|
+
// color: theme.palette.primary.light,
|
164
|
+
border: '2px solid #8b9898',
|
165
|
+
borderRadius: '50%',
|
166
|
+
color: `${theme.palette.neutral.dark} !important`,
|
165
167
|
fontWeight: theme.typography.fontWeightMedium
|
166
168
|
},
|
167
169
|
// Added to the day's cell outside the current month
|
@@ -186,6 +188,8 @@ export default (theme => ({
|
|
186
188
|
selected: {
|
187
189
|
// backgroundColor: fade(theme.palette.business.primary.normal, 0.36),
|
188
190
|
backgroundColor: theme.palette.primary.main,
|
189
|
-
color: theme.palette.primary.contrastText
|
191
|
+
color: theme.palette.primary.contrastText,
|
192
|
+
borderRadius: '0%',
|
193
|
+
border: 'none'
|
190
194
|
}
|
191
195
|
}));
|
@@ -12,6 +12,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
|
|
12
12
|
import withStyles from '../styles/withStyles';
|
13
13
|
import HiFormLabel from './HiFormLabel';
|
14
14
|
import { escapeHTML } from '../utils/helpers';
|
15
|
+
import keycode from 'keycode/index';
|
15
16
|
export const styles = theme => ({
|
16
17
|
helperTextClassName: {
|
17
18
|
color: theme.palette.neutral.main,
|
@@ -97,6 +98,14 @@ class HiFormControl extends React.PureComponent {
|
|
97
98
|
}
|
98
99
|
};
|
99
100
|
|
101
|
+
this.handleKeyDown = event => {
|
102
|
+
const key = keycode(event);
|
103
|
+
|
104
|
+
if (['space', 'enter'].includes(key)) {
|
105
|
+
this.handleHelperClick(event);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
100
109
|
this.handleHover = value => () => {
|
101
110
|
this.setState({
|
102
111
|
hovered: value
|
@@ -121,6 +130,7 @@ class HiFormControl extends React.PureComponent {
|
|
121
130
|
hovered: false
|
122
131
|
};
|
123
132
|
this.handleHelperClick = this.handleHelperClick.bind(this);
|
133
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
124
134
|
this.handleFocus = this.handleFocus.bind(this);
|
125
135
|
this.handleHover = this.handleHover.bind(this);
|
126
136
|
}
|
@@ -163,7 +173,12 @@ class HiFormControl extends React.PureComponent {
|
|
163
173
|
className: classes.errorDiv
|
164
174
|
}, React.createElement("div", {
|
165
175
|
className: classNames(classes.arrowDown, classes.errorDivArrowDown)
|
166
|
-
}),
|
176
|
+
}), React.createElement("span", {
|
177
|
+
// eslint-disable-next-line react/no-danger
|
178
|
+
dangerouslySetInnerHTML: {
|
179
|
+
__html: escapeHTML(errorText)
|
180
|
+
}
|
181
|
+
})), helperIcon && helperText && !error && helperOpen && React.createElement("div", {
|
167
182
|
className: classes.helperDiv
|
168
183
|
}, React.createElement("div", {
|
169
184
|
className: classNames(classes.arrowDown, classes.helperDivArrowDown)
|
@@ -180,12 +195,16 @@ class HiFormControl extends React.PureComponent {
|
|
180
195
|
focused: !disabled && (focused || hovered)
|
181
196
|
}, InputLabelProps), error && React.createElement(Warning, {
|
182
197
|
className: classes.errorIcon,
|
183
|
-
onClick: this.handleHelperClick
|
198
|
+
onClick: this.handleHelperClick,
|
199
|
+
tabIndex: 0,
|
200
|
+
onKeyDown: this.handleKeyDown
|
184
201
|
}), helperIcon && helperText && !error && React.createElement(Info, {
|
185
202
|
className: classNames(classes.helperIcon, {
|
186
203
|
[classes.helperIconActive]: helperOpen
|
187
204
|
}),
|
188
|
-
onClick: this.handleHelperClick
|
205
|
+
onClick: this.handleHelperClick,
|
206
|
+
tabIndex: 0,
|
207
|
+
onKeyDown: this.handleKeyDown
|
189
208
|
})), React.createElement("div", {
|
190
209
|
onMouseEnter: this.handleHover(true),
|
191
210
|
onMouseLeave: this.handleHover(false),
|
package/es/HiForm/HiInput.js
CHANGED