@hipay/hipay-material-ui 2.0.0-beta.63 → 2.0.0-beta.65

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,7 @@ var styles = function styles(theme) {
40
40
  overflow: 'hidden',
41
41
  position: 'relative',
42
42
  textAlign: 'right',
43
- paddingTop: '1em'
43
+ paddingTop: 10
44
44
  },
45
45
  trendChipIcon: {
46
46
  width: 14,
@@ -356,14 +356,12 @@ function (_React$PureComponent) {
356
356
  return _react.default.createElement("div", {
357
357
  className: classes.flexContainer
358
358
  }, _react.default.createElement("label", {
359
- htmlFor: "flat-button-file",
360
359
  ref: function ref(label) {
361
360
  _this2.uploadFieldRef = label;
362
361
  },
363
362
  tabIndex: "-1"
364
363
  }, _react.default.createElement("input", {
365
364
  hidden: true,
366
- id: "flat-button-file",
367
365
  type: !complete || values.length === 1 ? 'file' : 'hidden',
368
366
  onChange: this.handleChange,
369
367
  onClick: focusable ? this.handleEmptyField : undefined,
@@ -80,7 +80,7 @@ function (_React$PureComponent) {
80
80
  return id !== item.id;
81
81
  }), item);
82
82
  } else {
83
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
83
+ onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
84
84
  }
85
85
  };
86
86
 
@@ -91,14 +91,14 @@ function (_React$PureComponent) {
91
91
  var _this$props2 = _this.props,
92
92
  nextPage = _this$props2.nextPage,
93
93
  translations = _this$props2.translations;
94
- var itemList = [].concat((0, _toConsumableArray2.default)(options.length === 0 && !loading ? [{
94
+ var itemList = (0, _toConsumableArray2.default)(options.length === 0 && !loading ? [{
95
95
  id: '_no_result',
96
96
  type: 'text',
97
97
  disabled: true,
98
98
  centered: true,
99
99
  hideCheckbox: true,
100
100
  label: translations.no_result_match
101
- }] : []), (0, _toConsumableArray2.default)(options), (0, _toConsumableArray2.default)(!loading && nextPage === 'manual' ? [{
101
+ }] : []).concat((0, _toConsumableArray2.default)(options), (0, _toConsumableArray2.default)(!loading && nextPage === 'manual' ? [{
102
102
  id: '_next_page',
103
103
  type: 'button',
104
104
  centered: true,
@@ -135,9 +135,7 @@ function (_React$PureComponent) {
135
135
  other = (0, _objectWithoutProperties2.default)(_this$props3, ["hiSelectableListProps", "multiple", "nextPage", "options", "translations", "value"]);
136
136
  return _react.default.createElement(_HiSelect.default, (0, _extends2.default)({
137
137
  buildSelectProps: this.buildSelectProps,
138
- hiSelectableListProps: (0, _extends2.default)({
139
- onSelect: this.handleSelect
140
- }, hiSelectableListProps),
138
+ hiSelectableListProps: (0, _extends2.default)({}, hiSelectableListProps),
141
139
  multiple: multiple,
142
140
  options: options,
143
141
  searchable: true,
@@ -47,12 +47,12 @@ var _helpers = require("../utils/helpers");
47
47
  */
48
48
  function getRecursiveFinalItemIdList(itemList) {
49
49
  var finalItemIdList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
50
- return [].concat((0, _toConsumableArray2.default)(finalItemIdList), (0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
50
+ return (0, _toConsumableArray2.default)(finalItemIdList).concat((0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
51
51
  if (item.children) {
52
52
  return getRecursiveFinalItemIdList(item.children, memo);
53
53
  }
54
54
 
55
- return [].concat((0, _toConsumableArray2.default)(memo), [item.id]);
55
+ return (0, _toConsumableArray2.default)(memo).concat([item.id]);
56
56
  }, [])));
57
57
  }
58
58
  /**
@@ -128,7 +128,7 @@ function buildFilteredItemList(itemList) {
128
128
  }
129
129
 
130
130
  return {
131
- l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({}, item, disabledParent && {
131
+ l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({}, item, disabledParent && {
132
132
  disabled: true,
133
133
  hideCheckbox: true // don't display checkbox on disabled parent
134
134
 
@@ -147,7 +147,7 @@ function buildFilteredItemList(itemList) {
147
147
 
148
148
  var itemSelected = selectedItemIdList.includes(item.id);
149
149
  return {
150
- l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({
150
+ l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({
151
151
  displayed: itemVisible || visibleParent
152
152
  }, item)]),
153
153
  s: itemSelected && memoSelected,
@@ -266,9 +266,9 @@ function (_React$PureComponent) {
266
266
  }), item);
267
267
  } else {
268
268
  // select parent > add each selectable child without duplicates.
269
- onChange(event, [].concat((0, _toConsumableArray2.default)(value.filter(function (vid) {
269
+ onChange(event, (0, _toConsumableArray2.default)(value.filter(function (vid) {
270
270
  return !parentSelectableItemIdList.includes(vid);
271
- })), (0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
271
+ })).concat((0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
272
272
  }
273
273
  } else if (value.includes(item.id)) {
274
274
  // unselect item
@@ -276,7 +276,7 @@ function (_React$PureComponent) {
276
276
  return id !== item.id;
277
277
  }), item);
278
278
  } else {
279
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
279
+ onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
280
280
  }
281
281
  };
282
282
 
@@ -315,14 +315,14 @@ function (_React$PureComponent) {
315
315
  centered: true,
316
316
  hideCheckbox: true,
317
317
  label: translations.no_result_match
318
- }]) : [].concat((0, _toConsumableArray2.default)(loading ? [{
318
+ }]) : (0, _toConsumableArray2.default)(loading ? [{
319
319
  id: '_loading',
320
320
  type: 'loader',
321
321
  disabled: true,
322
322
  centered: true,
323
323
  hideCheckbox: true,
324
324
  label: 'loading'
325
- }] : []), (0, _toConsumableArray2.default)(hasAll ? [{
325
+ }] : []).concat((0, _toConsumableArray2.default)(hasAll ? [{
326
326
  id: '_all',
327
327
  iconAll: iconAll,
328
328
  label: translations.all,
@@ -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 [].concat((0, _toConsumableArray2.default)(finalItemIdList), (0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
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 [].concat((0, _toConsumableArray2.default)(memo), [item.id]);
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: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({}, item, disabledParent && {
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: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({
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, [].concat((0, _toConsumableArray2.default)(value.filter(function (vid) {
226
+ onChange(event, (0, _toConsumableArray2.default)(value.filter(function (vid) {
227
227
  return !parentSelectableItemIdList.includes(vid);
228
- })), (0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
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, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
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
- }]) : [].concat((0, _toConsumableArray2.default)(loading ? [{
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
- }] : []), (0, _toConsumableArray2.default)(hasAll ? [{
281
+ }] : []).concat((0, _toConsumableArray2.default)(hasAll ? [{
282
282
  id: '_all',
283
283
  iconAll: iconAll,
284
284
  label: translations.all,
@@ -149,22 +149,22 @@ function (_React$PureComponent) {
149
149
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
150
150
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
151
151
  // build item list
152
- var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
152
+ var itemList = (0, _toConsumableArray2.default)(loading ? [{
153
153
  id: '_loading',
154
154
  type: 'loader',
155
155
  disabled: true,
156
156
  centered: true,
157
157
  hideCheckbox: true,
158
158
  label: 'loading'
159
- }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
159
+ }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
160
160
  return _this.props.filterFunc(item, search);
161
- })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
161
+ })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
162
162
  id: '_all',
163
163
  label: _this.props.translations.all
164
164
  }, _this.props.iconAll && {
165
165
  type: 'icon',
166
166
  icon: _this.props.iconAll
167
- })] : []), (0, _toConsumableArray2.default)(options))));
167
+ })] : []).concat((0, _toConsumableArray2.default)(options))));
168
168
  return {
169
169
  itemList: itemList,
170
170
  inputValue: _this.buildInputValue(options, value, loading)
@@ -420,7 +420,7 @@ function (_React$PureComponent) {
420
420
  return id !== item.id;
421
421
  }), item);
422
422
  } else {
423
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
423
+ onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
424
424
  }
425
425
  };
426
426
 
@@ -446,13 +446,13 @@ function (_React$PureComponent) {
446
446
  });
447
447
  } else {
448
448
  _this.setState({
449
- suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
449
+ suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
450
450
  id: '_all',
451
451
  label: translations.all
452
452
  }, iconAll && {
453
453
  type: 'icon',
454
454
  icon: iconAll
455
- })] : []), (0, _toConsumableArray2.default)(suggestions))
455
+ })] : []).concat((0, _toConsumableArray2.default)(suggestions))
456
456
  });
457
457
  }
458
458
  };
@@ -179,7 +179,7 @@ function (_React$PureComponent) {
179
179
  return id !== item.id;
180
180
  }), item);
181
181
  } else {
182
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
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: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
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
- })] : []), (0, _toConsumableArray2.default)(suggestions))
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 = [].concat((0, _toConsumableArray2.default)(loading ? [{
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
- }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
261
+ }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
262
262
  return item.label && _this.props.filterFunc(item, search);
263
- })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
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
- })] : []), (0, _toConsumableArray2.default)(options))));
269
+ })] : []).concat((0, _toConsumableArray2.default)(options))));
270
270
  return {
271
271
  itemList: itemList
272
272
  };
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = exports.styles = void 0;
9
9
 
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
11
 
14
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -163,16 +161,32 @@ function (_React$PureComponent) {
163
161
  (0, _createClass2.default)(HiSelectableList, [{
164
162
  key: "componentDidMount",
165
163
  value: function componentDidMount() {
164
+ var _this2 = this;
165
+
166
+ // Focus on last item selected
166
167
  if (this.props.overlay && this.props.overlay.getElementsByTagName('li')[0]) {
167
168
  var item = this.props.overlay.getElementsByTagName('li')[0];
168
- var value = this.props.value && (0, _typeof2.default)(this.props.value) === 'object' ? this.props.value[0] : this.props.value;
169
-
170
- if (value) {
171
- if (typeof this.props.value[0] === 'string') {
172
- item = this.props.overlay.getElementsByTagName('li')[value];
173
- } else if (typeof this.props.value[0] === 'number') {
174
- item = this.props.overlay.getElementsByTagName('li')[value - 1];
175
- }
169
+
170
+ if (this.props.value) {
171
+ var lastSelectedValue = Array.isArray(this.props.value) ? this.props.value[this.props.value.length - 1] : this.props.value;
172
+ var index = 0;
173
+ this.props.itemList.forEach(function (option) {
174
+ if (option.id === lastSelectedValue) {
175
+ item = _this2.props.overlay.getElementsByTagName('li')[index];
176
+ }
177
+
178
+ index++;
179
+
180
+ if (option.children && option.children.length) {
181
+ option.children.forEach(function (option) {
182
+ if (option.id === lastSelectedValue) {
183
+ item = _this2.props.overlay.getElementsByTagName('li')[index];
184
+ }
185
+
186
+ index++;
187
+ });
188
+ }
189
+ });
176
190
  }
177
191
 
178
192
  item.focus();
@@ -181,7 +195,7 @@ function (_React$PureComponent) {
181
195
  }, {
182
196
  key: "render",
183
197
  value: function render() {
184
- var _this2 = this;
198
+ var _this3 = this;
185
199
 
186
200
  var _this$props2 = this.props,
187
201
  classes = _this$props2.classes,
@@ -196,13 +210,13 @@ function (_React$PureComponent) {
196
210
  className: classes.root,
197
211
  onKeyDown: this.handleKeyDown,
198
212
  innerRef: function innerRef(el) {
199
- _this2.el = el;
213
+ _this3.el = el;
200
214
  }
201
215
  }, itemList.filter(function (item) {
202
216
  return !(item.displayed === false);
203
217
  }) // don't remove if undefined
204
218
  .map(function (item) {
205
- return _this2.buildRecursiveListItem(item);
219
+ return _this3.buildRecursiveListItem(item);
206
220
  }));
207
221
  }
208
222
  }]);
@@ -12,7 +12,7 @@ export const styles = theme => ({
12
12
  overflow: 'hidden',
13
13
  position: 'relative',
14
14
  textAlign: 'right',
15
- paddingTop: '1em'
15
+ paddingTop: 10
16
16
  },
17
17
  trendChipIcon: {
18
18
  width: 14,
@@ -310,14 +310,12 @@ class HiUpload extends React.PureComponent {
310
310
  return React.createElement("div", {
311
311
  className: classes.flexContainer
312
312
  }, React.createElement("label", {
313
- htmlFor: "flat-button-file",
314
313
  ref: label => {
315
314
  this.uploadFieldRef = label;
316
315
  },
317
316
  tabIndex: "-1"
318
317
  }, React.createElement("input", {
319
318
  hidden: true,
320
- id: "flat-button-file",
321
319
  type: !complete || values.length === 1 ? 'file' : 'hidden',
322
320
  onChange: this.handleChange,
323
321
  onClick: focusable ? this.handleEmptyField : undefined,
@@ -102,9 +102,7 @@ class HiDynamicSelect extends React.PureComponent {
102
102
 
103
103
  return React.createElement(HiSelect, _extends({
104
104
  buildSelectProps: this.buildSelectProps,
105
- hiSelectableListProps: _objectSpread({
106
- onSelect: this.handleSelect
107
- }, hiSelectableListProps),
105
+ hiSelectableListProps: _objectSpread({}, hiSelectableListProps),
108
106
  multiple: multiple,
109
107
  options: options,
110
108
  searchable: true,
@@ -105,16 +105,30 @@ class HiSelectableList extends React.PureComponent {
105
105
  }
106
106
 
107
107
  componentDidMount() {
108
+ // Focus on last item selected
108
109
  if (this.props.overlay && this.props.overlay.getElementsByTagName('li')[0]) {
109
110
  let item = this.props.overlay.getElementsByTagName('li')[0];
110
- const value = this.props.value && typeof this.props.value === 'object' ? this.props.value[0] : this.props.value;
111
-
112
- if (value) {
113
- if (typeof this.props.value[0] === 'string') {
114
- item = this.props.overlay.getElementsByTagName('li')[value];
115
- } else if (typeof this.props.value[0] === 'number') {
116
- item = this.props.overlay.getElementsByTagName('li')[value - 1];
117
- }
111
+
112
+ if (this.props.value) {
113
+ let lastSelectedValue = Array.isArray(this.props.value) ? this.props.value[this.props.value.length - 1] : this.props.value;
114
+ let index = 0;
115
+ this.props.itemList.forEach(option => {
116
+ if (option.id === lastSelectedValue) {
117
+ item = this.props.overlay.getElementsByTagName('li')[index];
118
+ }
119
+
120
+ index++;
121
+
122
+ if (option.children && option.children.length) {
123
+ option.children.forEach(option => {
124
+ if (option.id === lastSelectedValue) {
125
+ item = this.props.overlay.getElementsByTagName('li')[index];
126
+ }
127
+
128
+ index++;
129
+ });
130
+ }
131
+ });
118
132
  }
119
133
 
120
134
  item.focus();
package/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license HiPay-Material-UI v2.0.0-beta.63
1
+ /** @license HiPay-Material-UI v2.0.0-beta.65
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license HiPay-Material-UI v2.0.0-beta.63
1
+ /** @license HiPay-Material-UI v2.0.0-beta.65
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
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.63",
4
+ "version": "2.0.0-beta.65",
6
5
  "description": "React components that implement Google's Material Design.",
7
6
  "keywords": [
8
7
  "react",