@hipay/hipay-material-ui 2.0.0-beta.58 → 2.0.0-beta.59

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.
@@ -144,10 +144,10 @@ class HiSuggestSelect extends React.PureComponent {
144
144
  options: [],
145
145
  focused: false
146
146
  });
147
- }
148
147
 
149
- if (this.props.onBlurInput) {
150
- this.props.onBlurInput(event);
148
+ if (this.props.onBlurInput) {
149
+ this.props.onBlurInput(event);
150
+ }
151
151
  }
152
152
  }
153
153
 
@@ -45,6 +45,10 @@ function findFinalItemRecursively(itemList, searchId) {
45
45
  });
46
46
  return foundItem;
47
47
  }
48
+
49
+ export var filterValue = function (item, searchValue) {
50
+ return searchValue === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(searchValue.toLowerCase())) !== -1;
51
+ };
48
52
  /**
49
53
  * Build item list by settings item props relative to the nested parent/child situation
50
54
  * Reduce the item list to build specified items (displayed, pinned, disabled, selected, indeterminate)
@@ -62,15 +66,14 @@ function findFinalItemRecursively(itemList, searchId) {
62
66
  * @returns {*}
63
67
  */
64
68
 
65
-
66
- function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue = '', visibleParent = false, pinnedParent = false, disabledParent = false, nbChildrenAsInfo = false, translations) {
69
+ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue = '', visibleParent = false, pinnedParent = false, disabledParent = false, nbChildrenAsInfo = false, translations, filterFunc = filterValue) {
67
70
  return itemList.reduce(({
68
71
  l: memoItemList,
69
72
  s: memoSelected,
70
73
  u: memoUnselected,
71
74
  v: memoVisible
72
75
  }, item) => {
73
- const itemVisible = searchValue === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(searchValue.toLowerCase())) !== -1; // Parent item
76
+ const itemVisible = filterFunc(item, searchValue); // Parent item
74
77
 
75
78
  if (item.children) {
76
79
  const {
@@ -78,7 +81,7 @@ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue =
78
81
  s: selected,
79
82
  u: unselected,
80
83
  v: visible
81
- } = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent);
84
+ } = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent, nbChildrenAsInfo, translations, filterFunc);
82
85
 
83
86
  if (nbChildrenAsInfo) {
84
87
  item.info = translations.n_children.replace('%s', item.children.length);
@@ -227,7 +230,8 @@ class HiNestedSelect extends React.PureComponent {
227
230
  multiple,
228
231
  nbChildrenAsInfo,
229
232
  pinnedParent,
230
- translations
233
+ translations,
234
+ filterFunc
231
235
  } = this.props; // build item list
232
236
 
233
237
  const {
@@ -235,7 +239,7 @@ class HiNestedSelect extends React.PureComponent {
235
239
  s: allSelected,
236
240
  u: allUnselected,
237
241
  v: visible
238
- } = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations);
242
+ } = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations, filterFunc);
239
243
  const itemList = !visible ? [...(loading ? [{
240
244
  id: '_loading',
241
245
  type: 'loader',
@@ -367,7 +371,8 @@ HiNestedSelect.defaultProps = {
367
371
  one_item_selected: '%s item selected',
368
372
  n_children: '%s',
369
373
  one_child: '%s item'
370
- }
374
+ },
375
+ filterFunc: filterValue
371
376
  };
372
377
  HiNestedSelect.propTypes = process.env.NODE_ENV !== "production" ? {
373
378
  /**
@@ -385,6 +390,11 @@ HiNestedSelect.propTypes = process.env.NODE_ENV !== "production" ? {
385
390
  */
386
391
  displayAsChip: PropTypes.bool,
387
392
 
393
+ /*
394
+ * Fonction de filtrage custom
395
+ */
396
+ filterFunc: PropTypes.func,
397
+
388
398
  /**
389
399
  * Affiche l'élément 'All'
390
400
  */
@@ -42,6 +42,9 @@ export function findFinalItemRecursively(itemList, searchId) {
42
42
  });
43
43
  return foundItem;
44
44
  }
45
+ export var filterValue = function (item, searchValue) {
46
+ return searchValue === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(searchValue.toLowerCase())) !== -1;
47
+ };
45
48
  /**
46
49
  * Build item list by settings item props relative to the nested parent/child situation
47
50
  * Reduce the item list to build specified items (displayed, pinned, disabled, selected, indeterminate)
@@ -59,14 +62,14 @@ export function findFinalItemRecursively(itemList, searchId) {
59
62
  * @returns {*}
60
63
  */
61
64
 
62
- function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue = '', visibleParent = false, pinnedParent = false, disabledParent = false, nbChildrenAsInfo = false, translations) {
65
+ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue = '', visibleParent = false, pinnedParent = false, disabledParent = false, nbChildrenAsInfo = false, translations, filterFunc = filterValue) {
63
66
  return itemList.reduce(({
64
67
  l: memoItemList,
65
68
  s: memoSelected,
66
69
  u: memoUnselected,
67
70
  v: memoVisible
68
71
  }, item) => {
69
- const itemVisible = searchValue === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(searchValue.toLowerCase())) !== -1; // Parent item
72
+ const itemVisible = filterFunc(item, searchValue); // Parent item
70
73
 
71
74
  if (item.children) {
72
75
  const {
@@ -74,7 +77,7 @@ function buildFilteredItemList(itemList, selectedItemIdList = [], searchValue =
74
77
  s: selected,
75
78
  u: unselected,
76
79
  v: visible
77
- } = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent);
80
+ } = buildFilteredItemList(item.children, selectedItemIdList, searchValue, itemVisible, pinnedParent, disabledParent, nbChildrenAsInfo, translations, filterFunc);
78
81
 
79
82
  if (nbChildrenAsInfo) {
80
83
  item.info = translations.n_children.replace('%s', item.children.length);
@@ -181,7 +184,8 @@ class HiNestedSelectContent extends React.PureComponent {
181
184
  multiple,
182
185
  nbChildrenAsInfo,
183
186
  pinnedParent,
184
- translations
187
+ translations,
188
+ filterFunc
185
189
  } = this.props; // build item list
186
190
 
187
191
  const {
@@ -189,7 +193,7 @@ class HiNestedSelectContent extends React.PureComponent {
189
193
  s: allSelected,
190
194
  u: allUnselected,
191
195
  v: visible
192
- } = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations);
196
+ } = buildFilteredItemList(options, value, search, false, pinnedParent, disabledParent || !multiple, nbChildrenAsInfo, translations, filterFunc);
193
197
  const itemList = !visible ? [...(loading ? [{
194
198
  id: '_loading',
195
199
  type: 'loader',
@@ -272,7 +276,8 @@ HiNestedSelectContent.defaultProps = {
272
276
  search: 'Search',
273
277
  n_children: '%s',
274
278
  one_child: '%s item'
275
- }
279
+ },
280
+ filterFunc: filterValue
276
281
  };
277
282
  HiNestedSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
278
283
  /**
@@ -285,6 +290,11 @@ HiNestedSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
285
290
  */
286
291
  disabledParent: PropTypes.bool,
287
292
 
293
+ /*
294
+ * Fonction de filtrage custom
295
+ */
296
+ filterFunc: PropTypes.func,
297
+
288
298
  /**
289
299
  * Affiche l'élément 'All'
290
300
  */
@@ -68,6 +68,10 @@ export const styles = theme => ({
68
68
  borderTop: `1px solid ${theme.palette.input.bottomLine}`
69
69
  }
70
70
  });
71
+
72
+ function filterValue(item, search) {
73
+ return search === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(search.toLowerCase())) !== -1;
74
+ }
71
75
  /**
72
76
  *
73
77
  * Utilisé pour tous types de selects dans les formulaires.
@@ -83,6 +87,7 @@ export const styles = theme => ({
83
87
  * - HiSelectableList : affiche la liste des suggestions selon le type des éléments
84
88
  */
85
89
 
90
+
86
91
  class HiSelect extends React.PureComponent {
87
92
  constructor(props) {
88
93
  super(props);
@@ -97,7 +102,7 @@ class HiSelect extends React.PureComponent {
97
102
  hideCheckbox: true,
98
103
  label: 'loading'
99
104
  }] : []), // simple one level filter on label
100
- ...(search !== '' ? [...options.filter(item => item.label && foldAccents(item.label.toString().toLowerCase()).search(foldAccents(search.toLowerCase())) !== -1)] : [...(this.props.hasAll ? [_objectSpread({
105
+ ...(search !== '' ? [...options.filter(item => this.props.filterFunc(item, search))] : [...(this.props.hasAll ? [_objectSpread({
101
106
  id: '_all',
102
107
  label: this.props.translations.all
103
108
  }, this.props.iconAll && {
@@ -204,20 +209,22 @@ class HiSelect extends React.PureComponent {
204
209
  };
205
210
 
206
211
  this.focusOnSelectedItem = selectedValue => {
207
- setTimeout(() => {
208
- // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
209
- let item = this.overlay.getElementsByTagName('li')[0];
210
-
211
- if (selectedValue && typeof selectedValue === 'string') {
212
- item = this.overlay.getElementsByTagName('li')[selectedValue];
213
- } else if (selectedValue && typeof selectedValue === 'number') {
214
- item = this.overlay.getElementsByTagName('li')[selectedValue - 1];
215
- }
212
+ if (this.overlay && this.overlay.getElementsByTagName('li')[0]) {
213
+ setTimeout(() => {
214
+ // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
215
+ let item = this.overlay.getElementsByTagName('li')[0];
216
216
 
217
- if (item) {
218
- item.focus();
219
- }
220
- }, 1);
217
+ if (selectedValue && typeof selectedValue === 'string') {
218
+ item = this.overlay.getElementsByTagName('li')[selectedValue];
219
+ } else if (selectedValue && typeof selectedValue === 'number') {
220
+ item = this.overlay.getElementsByTagName('li')[selectedValue - 1];
221
+ }
222
+
223
+ if (item) {
224
+ item.focus();
225
+ }
226
+ }, 1);
227
+ }
221
228
  };
222
229
 
223
230
  this.handleClickAway = event => {
@@ -676,7 +683,8 @@ HiSelect.defaultProps = {
676
683
  n_children: '%s items',
677
684
  one_child: '%s item'
678
685
  },
679
- type: 'text'
686
+ type: 'text',
687
+ filterFunc: filterValue
680
688
  };
681
689
  HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
682
690
  align: PropTypes.oneOf(['left', 'right']),
@@ -711,6 +719,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
711
719
  */
712
720
  fallbackImage: PropTypes.string,
713
721
 
722
+ /*
723
+ * Fonction de filtrage custom
724
+ */
725
+ filterFunc: PropTypes.func,
726
+
714
727
  /**
715
728
  * Affiche l'élément 'All'
716
729
  */
@@ -37,6 +37,9 @@ export const styles = theme => ({
37
37
  width: '100%'
38
38
  })
39
39
  });
40
+ export var filterValue = function (item, searchValue) {
41
+ return searchValue === '' || foldAccents(item.label.toString().toLowerCase()).search(foldAccents(searchValue.toLowerCase())) !== -1;
42
+ };
40
43
  /**
41
44
  *
42
45
  * Utilisé pour tous types de selects dans les formulaires.
@@ -197,7 +200,7 @@ class HiSelectContent extends React.PureComponent {
197
200
  hideCheckbox: true,
198
201
  label: 'loading'
199
202
  }] : []), // simple one level filter on label
200
- ...(search !== '' ? [...options.filter(item => item.label && foldAccents(item.label.toString().toLowerCase()).search(foldAccents(search.toLowerCase())) !== -1)] : [...(this.props.hasAll ? [_objectSpread({
203
+ ...(search !== '' ? [...options.filter(item => item.label && this.props.filterFunc(item, search))] : [...(this.props.hasAll ? [_objectSpread({
201
204
  id: '_all',
202
205
  label: this.props.translations.all
203
206
  }, this.props.iconAll && {
@@ -331,7 +334,8 @@ HiSelectContent.defaultProps = {
331
334
  n_children: '%s items',
332
335
  one_child: '%s item'
333
336
  },
334
- type: 'text'
337
+ type: 'text',
338
+ filterFunc: filterValue
335
339
  };
336
340
  HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
337
341
  autoHeight: PropTypes.bool,
@@ -356,6 +360,11 @@ HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
356
360
  */
357
361
  fallbackImage: PropTypes.string,
358
362
 
363
+ /*
364
+ * Fonction de filtrage custom
365
+ */
366
+ filterFunc: PropTypes.func,
367
+
359
368
  /**
360
369
  * Affiche l'élément 'All'
361
370
  */
@@ -127,7 +127,6 @@ class HiSelectInput extends React.PureComponent {
127
127
 
128
128
  if (this.props.onKeyDown) {
129
129
  this.props.onKeyDown(event);
130
- event.preventDefault();
131
130
  } else if (key === 'down' || key === 'up') {
132
131
  this.props.onClick();
133
132
  } else if (key === 'enter' && this.props.onSubmit) {
@@ -167,9 +166,11 @@ class HiSelectInput extends React.PureComponent {
167
166
  this.handleBlur = event => {
168
167
  if ((!this.input || !this.input.contains(event.relatedTarget)) && this.props.onBlur) {
169
168
  this.props.onBlur(event);
170
- } else if (this.input && (!this.resetIcon || !this.resetIcon.contains(event.relatedTarget))) {
171
- this.input.focus();
172
169
  }
170
+ /* else if (this.input && (!this.resetIcon || !this.resetIcon.contains(event.relatedTarget))) {
171
+ this.input.focus();
172
+ }*/
173
+
173
174
  };
174
175
 
175
176
  this.ref = el => {
@@ -85,12 +85,13 @@ export const styles = theme => ({
85
85
  minWidth: '50%',
86
86
  padding: '5px 0',
87
87
  '&$listItemContentSelected': {
88
- marginBottom: -3,
88
+ marginBottom: 1,
89
89
  marginLeft: -4
90
90
  },
91
91
  '& strong': {
92
92
  fontWeight: theme.typography.fontWeightMedium
93
- }
93
+ },
94
+ display: 'inline-flex'
94
95
  }),
95
96
  listItemContentSelected: {},
96
97
  label: {
@@ -136,7 +137,7 @@ export const styles = theme => ({
136
137
  labelContent: {
137
138
  display: 'flex',
138
139
  alignItems: 'center',
139
- maxWidth: '70%',
140
+ maxWidth: '85%',
140
141
  '&$labelWithoutSecondaryInline': {
141
142
  maxWidth: '100%'
142
143
  }
@@ -225,7 +226,8 @@ class HiSelectableListItem extends React.PureComponent {
225
226
  }
226
227
 
227
228
  return React.createElement("div", {
228
- className: classes.label
229
+ className: classes.label,
230
+ title: label
229
231
  }, label);
230
232
  }
231
233
 
package/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license HiPay-Material-UI v2.0.0-beta.58
1
+ /** @license HiPay-Material-UI v2.0.0-beta.59
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.58
1
+ /** @license HiPay-Material-UI v2.0.0-beta.59
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
@@ -2,7 +2,7 @@
2
2
  "name": "@hipay/hipay-material-ui",
3
3
  "private": false,
4
4
  "author": "HiPay PSYCHE Team",
5
- "version": "2.0.0-beta.58",
5
+ "version": "2.0.0-beta.59",
6
6
  "description": "React components that implement Google's Material Design.",
7
7
  "keywords": [
8
8
  "react",