@hipay/hipay-material-ui 1.0.0-beta.3 → 1.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/HiDatePicker/HiDatePicker.js +12 -14
- package/HiForm/HiFormControl.js +4 -1
- package/HiForm/HiInput.js +4 -4
- package/HiForm/HiSearchField.js +1 -1
- package/HiSelect/HiSelect.js +285 -257
- package/HiSelect/HiSelectField.js +8 -6
- package/HiSelect/HiSuggestSelect.js +25 -47
- package/HiSelect/HiSuggestSelectField.js +88 -80
- package/HiSelect/SelectInput.js +32 -21
- package/HiSelectableList/HiSelectableListItem.js +3 -0
- package/HiTopBar/HiTopBar.js +16 -12
- package/es/HiDatePicker/HiDatePicker.js +12 -14
- package/es/HiForm/HiFormControl.js +4 -1
- package/es/HiForm/HiInput.js +4 -4
- package/es/HiForm/HiSearchField.js +1 -1
- package/es/HiSelect/HiSelect.js +261 -229
- package/es/HiSelect/HiSelectField.js +9 -7
- package/es/HiSelect/HiSuggestSelect.js +24 -39
- package/es/HiSelect/HiSuggestSelectField.js +77 -69
- package/es/HiSelect/SelectInput.js +42 -21
- package/es/HiSelectableList/HiSelectableListItem.js +3 -0
- package/es/HiTopBar/HiTopBar.js +16 -8
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +8684 -8694
- package/umd/hipay-material-ui.production.min.js +5 -5
@@ -4,17 +4,12 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutPropert
|
|
4
4
|
|
5
5
|
import React from 'react';
|
6
6
|
import PropTypes from 'prop-types';
|
7
|
-
|
8
|
-
import classNames from 'classnames';
|
9
7
|
import { findDOMNode } from 'react-dom';
|
10
8
|
import Grow from 'material-ui/transitions/Grow';
|
11
9
|
import Paper from 'material-ui/Paper';
|
12
|
-
import ClickAwayListener from 'material-ui/utils/ClickAwayListener';
|
13
10
|
import { Manager, Target, Popper } from 'react-popper';
|
14
|
-
|
15
11
|
import HiSelectableList from '../HiSelectableList';
|
16
12
|
import HiInput from '../HiForm/HiInput';
|
17
|
-
|
18
13
|
import { withStyles } from '../styles';
|
19
14
|
import { getNextItemSelectable } from '../utils/hiHelpers';
|
20
15
|
|
@@ -22,7 +17,7 @@ export const styles = theme => ({
|
|
22
17
|
root: {
|
23
18
|
backgroundColor: theme.palette.background2,
|
24
19
|
maxWidth: 500,
|
25
|
-
minWidth:
|
20
|
+
minWidth: 200,
|
26
21
|
width: '100%'
|
27
22
|
},
|
28
23
|
popper: {
|
@@ -31,9 +26,6 @@ export const styles = theme => ({
|
|
31
26
|
zIndex: 9,
|
32
27
|
top: '100%'
|
33
28
|
},
|
34
|
-
popperClose: {
|
35
|
-
pointerEvents: 'none'
|
36
|
-
},
|
37
29
|
paper: {
|
38
30
|
borderRadius: '0px 2px',
|
39
31
|
maxHeight: 440,
|
@@ -94,34 +86,29 @@ class HiSuggestSelect extends React.PureComponent {
|
|
94
86
|
};
|
95
87
|
|
96
88
|
this.handleSelect = this.handleSelect.bind(this);
|
97
|
-
this.handleClose = this.handleClose.bind(this);
|
98
89
|
this.handleBlur = this.handleBlur.bind(this);
|
90
|
+
this.handleFocus = this.handleFocus.bind(this);
|
99
91
|
}
|
100
92
|
|
101
93
|
componentWillReceiveProps(nextProps) {
|
102
94
|
this.setState({ options: nextProps.options });
|
103
95
|
}
|
104
96
|
|
105
|
-
handleClose() {
|
106
|
-
document.body.style.overflow = 'auto';
|
107
|
-
this.setState({
|
108
|
-
focused: false, // TODO - Make difference between open and focus
|
109
|
-
options: []
|
110
|
-
});
|
111
|
-
}
|
112
|
-
|
113
97
|
// Key down on list items
|
114
98
|
|
115
99
|
|
116
100
|
// Key down on search input
|
117
101
|
|
118
102
|
|
103
|
+
handleFocus() {
|
104
|
+
this.setState({ focused: true });
|
105
|
+
}
|
106
|
+
|
119
107
|
handleBlur(event) {
|
120
108
|
// Si on click sur un élément de HiInput, on garde le focus
|
121
109
|
// Par exemple sur l'icone reset
|
122
|
-
const overlay = this.overlay;
|
123
110
|
if (!event.relatedTarget || !this.overlay || !this.overlay.contains(event.relatedTarget)) {
|
124
|
-
this.setState({ options: [] });
|
111
|
+
this.setState({ options: [], focused: false });
|
125
112
|
}
|
126
113
|
}
|
127
114
|
|
@@ -131,7 +118,8 @@ class HiSuggestSelect extends React.PureComponent {
|
|
131
118
|
otherProps = _objectWithoutProperties(_props, ['classes', 'translations', 'id', 'onSearch']);
|
132
119
|
|
133
120
|
const { focused, options } = this.state;
|
134
|
-
const open = !!options.length;
|
121
|
+
const open = !!options.length && focused;
|
122
|
+
|
135
123
|
return React.createElement(
|
136
124
|
'div',
|
137
125
|
{
|
@@ -154,7 +142,8 @@ class HiSuggestSelect extends React.PureComponent {
|
|
154
142
|
},
|
155
143
|
onChange: onSearch,
|
156
144
|
onKeyDown: this.handleKeyDownSearch,
|
157
|
-
onBlur: this.handleBlur
|
145
|
+
onBlur: this.handleBlur,
|
146
|
+
onFocus: this.handleFocus
|
158
147
|
}))
|
159
148
|
),
|
160
149
|
open && React.createElement(
|
@@ -162,26 +151,22 @@ class HiSuggestSelect extends React.PureComponent {
|
|
162
151
|
{
|
163
152
|
placement: 'bottom-start',
|
164
153
|
eventsEnabled: open,
|
165
|
-
className:
|
154
|
+
className: classes.popper
|
166
155
|
},
|
167
156
|
React.createElement(
|
168
|
-
|
169
|
-
{
|
157
|
+
Grow,
|
158
|
+
{ 'in': open, id: 'menu-list', style: { transformOrigin: '0 0 0' } },
|
170
159
|
React.createElement(
|
171
|
-
|
172
|
-
{
|
173
|
-
React.createElement(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
translations: translations,
|
182
|
-
onKeyDown: this.handleKeyDown
|
183
|
-
})
|
184
|
-
)
|
160
|
+
Paper,
|
161
|
+
{ className: classes.paper },
|
162
|
+
React.createElement(HiSelectableList, {
|
163
|
+
itemList: options,
|
164
|
+
selectedIdList: [],
|
165
|
+
checkbox: false,
|
166
|
+
onSelect: this.handleSelect,
|
167
|
+
translations: translations,
|
168
|
+
onKeyDown: this.handleKeyDown
|
169
|
+
})
|
185
170
|
)
|
186
171
|
)
|
187
172
|
)
|
@@ -12,78 +12,86 @@ import HiSuggestSelect from './HiSuggestSelect';
|
|
12
12
|
*/
|
13
13
|
class HiSuggestSelectField extends React.PureComponent {
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
render() {
|
16
|
+
const _props = this.props,
|
17
|
+
{
|
18
|
+
label,
|
19
|
+
required,
|
20
|
+
disabled,
|
21
|
+
error,
|
22
|
+
errorText,
|
23
|
+
helperText,
|
24
|
+
helperIcon,
|
25
|
+
id,
|
26
|
+
className
|
27
|
+
} = _props,
|
28
|
+
others = _objectWithoutProperties(_props, ['label', 'required', 'disabled', 'error', 'errorText', 'helperText', 'helperIcon', 'id', 'className']);
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
30
|
+
return React.createElement(
|
31
|
+
HiFormControl,
|
32
|
+
{
|
33
|
+
id: id,
|
34
|
+
label: label,
|
35
|
+
required: required,
|
36
|
+
disabled: disabled,
|
37
|
+
error: error,
|
38
|
+
errorText: errorText,
|
39
|
+
helperText: helperText,
|
40
|
+
helperIcon: helperIcon,
|
41
|
+
className: className
|
42
|
+
},
|
43
|
+
React.createElement(HiSuggestSelect, _extends({
|
44
|
+
id: id,
|
45
|
+
translations: {
|
46
|
+
all: 'Tous les pays',
|
47
|
+
no_result_match: 'Aucun résultat correspondant',
|
48
|
+
search: 'Recherche',
|
49
|
+
n_items_selected: '%s pays sélectionnés',
|
50
|
+
one_item_selected: '%s pays sélectionné'
|
51
|
+
},
|
52
|
+
disabled: disabled,
|
53
|
+
error: error
|
54
|
+
}, others))
|
55
|
+
);
|
56
|
+
}
|
53
57
|
}
|
54
58
|
|
55
59
|
HiSuggestSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
60
|
+
/**
|
61
|
+
* Surcharge des styles
|
62
|
+
*/
|
63
|
+
className: PropTypes.string,
|
64
|
+
/**
|
65
|
+
* Si `true`, l'input sera inactif.
|
66
|
+
*/
|
67
|
+
disabled: PropTypes.bool,
|
68
|
+
/**
|
69
|
+
* Si `true`, le champs sera en erreur.
|
70
|
+
*/
|
71
|
+
error: PropTypes.bool,
|
72
|
+
/**
|
73
|
+
* Texte de l'erreur
|
74
|
+
*/
|
75
|
+
errorText: PropTypes.string,
|
76
|
+
/**
|
77
|
+
* Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
|
78
|
+
*/
|
79
|
+
helperIcon: PropTypes.bool,
|
80
|
+
/**
|
81
|
+
* Texte de l'aide
|
82
|
+
*/
|
83
|
+
helperText: PropTypes.string,
|
84
|
+
/**
|
85
|
+
* id de l'élément input
|
86
|
+
*/
|
87
|
+
id: PropTypes.string,
|
88
|
+
/**
|
89
|
+
* Label du champs
|
90
|
+
*/
|
91
|
+
label: PropTypes.string,
|
92
|
+
/**
|
93
|
+
* true si champs obligatoire
|
94
|
+
*/
|
95
|
+
required: PropTypes.bool
|
88
96
|
} : {};
|
89
97
|
export default HiSuggestSelectField;
|
@@ -47,7 +47,7 @@ export const styles = theme => ({
|
|
47
47
|
},
|
48
48
|
inkbar: {
|
49
49
|
'&:not($disabled)': {
|
50
|
-
'&:after': {
|
50
|
+
'&:not($error):after': {
|
51
51
|
backgroundColor: theme.palette.business.primary.normal,
|
52
52
|
left: 0,
|
53
53
|
bottom: 0,
|
@@ -135,7 +135,18 @@ class SelectInput extends React.PureComponent {
|
|
135
135
|
}
|
136
136
|
|
137
137
|
render() {
|
138
|
-
const {
|
138
|
+
const {
|
139
|
+
classes,
|
140
|
+
noButton,
|
141
|
+
disabled,
|
142
|
+
onClick,
|
143
|
+
value,
|
144
|
+
open,
|
145
|
+
focused,
|
146
|
+
error,
|
147
|
+
id,
|
148
|
+
refElement
|
149
|
+
} = this.props;
|
139
150
|
|
140
151
|
// On utilise classNames pour variabiliser les styles et merge les classes appliquées
|
141
152
|
const rootClass = classNames(classes.root, classes.inkbar, classes.underline, {
|
@@ -162,7 +173,10 @@ class SelectInput extends React.PureComponent {
|
|
162
173
|
onFocus: this.props.onFocus,
|
163
174
|
onBlur: this.props.onBlur,
|
164
175
|
role: 'button',
|
165
|
-
tabIndex: '0'
|
176
|
+
tabIndex: '0',
|
177
|
+
ref: el => {
|
178
|
+
refElement && refElement(el);
|
179
|
+
}
|
166
180
|
},
|
167
181
|
React.createElement(
|
168
182
|
'span',
|
@@ -181,7 +195,10 @@ class SelectInput extends React.PureComponent {
|
|
181
195
|
onMouseLeave: this.props.onMouseLeave,
|
182
196
|
onKeyDown: this.handleKeyDown,
|
183
197
|
onFocus: this.props.onFocus,
|
184
|
-
onBlur: this.props.onBlur
|
198
|
+
onBlur: this.props.onBlur,
|
199
|
+
buttonRef: el => {
|
200
|
+
refElement && refElement(el);
|
201
|
+
}
|
185
202
|
},
|
186
203
|
React.createElement(
|
187
204
|
'span',
|
@@ -216,6 +233,23 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
216
233
|
* If `true`, the select will be disabled.
|
217
234
|
*/
|
218
235
|
disabled: PropTypes.bool,
|
236
|
+
/**
|
237
|
+
* Applique le style error
|
238
|
+
*/
|
239
|
+
error: PropTypes.bool,
|
240
|
+
/**
|
241
|
+
* Applique le style focused
|
242
|
+
*/
|
243
|
+
focused: PropTypes.bool,
|
244
|
+
/**
|
245
|
+
* id du select
|
246
|
+
*/
|
247
|
+
id: PropTypes.string,
|
248
|
+
/**
|
249
|
+
* Affiche sous forme de div à la place d'un bouton.
|
250
|
+
* Si des éléments cliquables sont à l'intérieur.
|
251
|
+
*/
|
252
|
+
noButton: PropTypes.bool,
|
219
253
|
/**
|
220
254
|
* Fonction de callback au blur du bouton
|
221
255
|
*/
|
@@ -232,30 +266,17 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
232
266
|
* Fonction de callback à la pression de touche
|
233
267
|
*/
|
234
268
|
onKeyDown: PropTypes.func,
|
235
|
-
/**
|
236
|
-
* Valeur à afficher (déjà formattée)
|
237
|
-
*/
|
238
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),
|
239
269
|
/**
|
240
270
|
* Applique le style open et effectue une rotation de l'icône
|
241
271
|
*/
|
242
272
|
open: PropTypes.bool,
|
243
273
|
/**
|
244
|
-
*
|
245
|
-
* Si des éléments cliquables sont à l'intérieur.
|
246
|
-
*/
|
247
|
-
noButton: PropTypes.bool,
|
248
|
-
/**
|
249
|
-
* Applique le style focused
|
250
|
-
*/
|
251
|
-
focused: PropTypes.bool,
|
252
|
-
/**
|
253
|
-
* Applique le style error
|
274
|
+
* Use that property to pass a ref callback to the native component.
|
254
275
|
*/
|
255
|
-
|
276
|
+
refElement: PropTypes.func,
|
256
277
|
/**
|
257
|
-
*
|
278
|
+
* Valeur à afficher (déjà formattée)
|
258
279
|
*/
|
259
|
-
|
280
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node])
|
260
281
|
} : {};
|
261
282
|
export default withStyles(styles, { name: 'HmuiSelectInput' })(SelectInput);
|
@@ -55,6 +55,9 @@ export const styles = theme => ({
|
|
55
55
|
marginLeft: theme.spacing.unit
|
56
56
|
}),
|
57
57
|
listItemInfoText: _extends({
|
58
|
+
whiteSpace: 'nowrap',
|
59
|
+
overflow: 'hidden',
|
60
|
+
textOverflow: 'ellipsis',
|
58
61
|
color: theme.palette.neutral.normal
|
59
62
|
}, theme.typography.body4, {
|
60
63
|
fontWeight: theme.typography.fontWeightRegular,
|
package/es/HiTopBar/HiTopBar.js
CHANGED
@@ -128,7 +128,7 @@ class HiTopBar extends React.Component {
|
|
128
128
|
menuAnchor: null
|
129
129
|
};
|
130
130
|
|
131
|
-
this.
|
131
|
+
this.handleCollapse = this.handleCollapse.bind(this);
|
132
132
|
this.handleClickMenu = this.handleClickMenu.bind(this);
|
133
133
|
this.handleOpenMenu = this.handleOpenMenu.bind(this);
|
134
134
|
this.handleCloseMenu = this.handleCloseMenu.bind(this);
|
@@ -148,7 +148,7 @@ class HiTopBar extends React.Component {
|
|
148
148
|
callback();
|
149
149
|
}
|
150
150
|
|
151
|
-
|
151
|
+
handleCollapse() {
|
152
152
|
this.setState({ collapsed: !this.state.collapsed });
|
153
153
|
}
|
154
154
|
|
@@ -168,6 +168,7 @@ class HiTopBar extends React.Component {
|
|
168
168
|
translations,
|
169
169
|
onClickMenu,
|
170
170
|
accountSelectorContent,
|
171
|
+
refButtons,
|
171
172
|
searchInput,
|
172
173
|
searchFocus
|
173
174
|
} = this.props;
|
@@ -204,15 +205,18 @@ class HiTopBar extends React.Component {
|
|
204
205
|
null,
|
205
206
|
React.createElement(
|
206
207
|
Collapse,
|
207
|
-
{
|
208
|
+
{
|
209
|
+
'in': !this.state.collapsed,
|
210
|
+
className: classNames({
|
208
211
|
[classes.collapseOverflow]: !hideable
|
209
|
-
})
|
212
|
+
})
|
213
|
+
},
|
210
214
|
React.createElement(
|
211
215
|
Toolbar,
|
212
216
|
{ className: classes.toolbar },
|
213
217
|
React.createElement(
|
214
218
|
'div',
|
215
|
-
{ ref:
|
219
|
+
{ ref: refButtons },
|
216
220
|
searchFocus ? React.createElement(
|
217
221
|
HiButton,
|
218
222
|
{
|
@@ -268,7 +272,7 @@ class HiTopBar extends React.Component {
|
|
268
272
|
(hideable || hasSettings) && React.createElement(
|
269
273
|
IconButton,
|
270
274
|
{ color: 'inherit', className: classes.iconButton },
|
271
|
-
hideable && React.createElement(ChevronDoubleUp, { onClick: this.
|
275
|
+
hideable && React.createElement(ChevronDoubleUp, { onClick: this.handleCollapse }),
|
272
276
|
hasSettings && React.createElement(HiIconBuilder, {
|
273
277
|
onClick: this.props.onClickSettings,
|
274
278
|
icon: 'fa-gear',
|
@@ -280,7 +284,7 @@ class HiTopBar extends React.Component {
|
|
280
284
|
hideable && this.state.collapsed && React.createElement(
|
281
285
|
IconButton,
|
282
286
|
{
|
283
|
-
onClick: this.
|
287
|
+
onClick: this.handleCollapse,
|
284
288
|
color: 'inherit',
|
285
289
|
className: classes.showTopBarButton
|
286
290
|
},
|
@@ -296,7 +300,7 @@ class HiTopBar extends React.Component {
|
|
296
300
|
{ className: classes.toolbar },
|
297
301
|
React.createElement(
|
298
302
|
'div',
|
299
|
-
{ ref:
|
303
|
+
{ ref: refButtons },
|
300
304
|
searchFocus ? React.createElement(
|
301
305
|
IconButton,
|
302
306
|
{ className: classes.leftButtonMobile, color: 'inherit' },
|
@@ -434,6 +438,10 @@ HiTopBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
434
438
|
* [here](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
|
435
439
|
*/
|
436
440
|
position: PropTypes.oneOf(['fixed', 'absolute', 'sticky', 'static']),
|
441
|
+
/**
|
442
|
+
* Passe une ref callback à la div contenant les boutons "menu" et "back"
|
443
|
+
*/
|
444
|
+
refButtons: PropTypes.func,
|
437
445
|
/**
|
438
446
|
* Etat de focus.
|
439
447
|
*/
|
package/index.es.js
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@hipay/hipay-material-ui",
|
3
3
|
"private": false,
|
4
4
|
"author": "HiPay PSYCHE Team",
|
5
|
-
"version": "1.0.0-beta.
|
5
|
+
"version": "1.0.0-beta.4",
|
6
6
|
"description": "HiPay Material-UI Style Guide - React components that implement Google's Material Design from Material-UI.",
|
7
7
|
"main": "./index.js",
|
8
8
|
"repository": {
|