@nestio/pam 2.0.5-beta.4 → 2.0.6
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/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/modules.xml +8 -0
- package/.idea/pam.iml +15 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +26 -0
- package/examples/components/Select.jsx +12 -26
- package/examples/index.html +0 -5
- package/lib/components/MultiSelect.js +3 -3
- package/lib/components/MultiSelectOption.js +3 -22
- package/lib/components/OptionListSet.js +3 -11
- package/lib/components/SelectCore.js +26 -84
- package/lib/components/SelectOption.js +11 -44
- package/lib/components/SingleSelect.js +0 -2
- package/lib/components/TagBoxMenuSelect.js +0 -2
- package/lib/components/styles/MultiSelectOption.scss +0 -4
- package/lib/components/styles/SelectOption.scss +0 -12
- package/lib/components/styles/_variables.scss +0 -1
- package/lib/components/styles/icons/05a4d7fb.eot +0 -0
- package/lib/components/styles/icons/05a4d7fb.otf +0 -0
- package/lib/components/styles/icons/05a4d7fb.ttf +0 -0
- package/lib/components/styles/icons/05a4d7fb.woff +0 -0
- package/lib/components/styles/icons/icons.css +57 -1
- package/package.json +3 -3
- package/src/components/MultiSelect.jsx +2 -2
- package/src/components/MultiSelectOption.jsx +3 -21
- package/src/components/OptionListSet.jsx +2 -9
- package/src/components/SelectCore.jsx +11 -62
- package/src/components/SelectOption.jsx +8 -27
- package/src/components/SingleSelect.jsx +0 -2
- package/src/components/TagBoxMenuSelect.jsx +0 -2
- package/src/components/__tests__/MultiSelect.spec.js +2 -0
- package/src/components/__tests__/MultiSelectOption.spec.js +2 -42
- package/src/components/__tests__/OptionListSet.spec.js +1 -24
- package/src/components/__tests__/SelectCore.spec.js +0 -103
- package/src/components/__tests__/SelectOption.spec.js +2 -33
- package/src/components/__tests__/SingleSelectOption.spec.js +1 -2
- package/src/components/styles/MultiSelectOption.scss +0 -4
- package/src/components/styles/SelectOption.scss +0 -12
- package/src/components/styles/_variables.scss +0 -1
- package/src/components/styles/icons/05a4d7fb.eot +0 -0
- package/src/components/styles/icons/05a4d7fb.otf +0 -0
- package/src/components/styles/icons/05a4d7fb.ttf +0 -0
- package/src/components/styles/icons/05a4d7fb.woff +0 -0
- package/src/components/styles/icons/icons.css +57 -1
- package/lib/components/Collapse.js +0 -50
- package/lib/constants.js +0 -7
- package/src/components/Collapse.jsx +0 -30
- package/src/components/__tests__/Collapse.spec.js +0 -26
- package/src/constants.js +0 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1,57 @@
|
|
|
1
|
-
@font-face
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: 'Pam';
|
|
3
|
+
src: url('./05a4d7fb.eot');
|
|
4
|
+
src: url('./05a4d7fb.eot?#iefix') format('embedded-opentype'),
|
|
5
|
+
url('./05a4d7fb.woff') format('woff'),
|
|
6
|
+
url('./05a4d7fb.ttf') format('truetype'),
|
|
7
|
+
url('./05a4d7fb.otf') format('opentype');
|
|
8
|
+
font-weight: normal;
|
|
9
|
+
font-style: normal;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.pamicon {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
font: normal normal normal 14px/1 'Pam';
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
text-rendering: auto;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
-moz-osx-font-smoothing: grayscale;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pamicon-lg {
|
|
22
|
+
font-size: 1.33333333em;
|
|
23
|
+
line-height: 0.75em;
|
|
24
|
+
vertical-align: -15%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pamicon-2x {
|
|
28
|
+
font-size: 2em;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.pamicon-3x {
|
|
32
|
+
font-size: 3em;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.pamicon-4x {
|
|
36
|
+
font-size: 4em;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pamicon-5x {
|
|
40
|
+
font-size: 5em;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.pamicon-checkbox-checked:before {
|
|
44
|
+
content: '\f000';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.pamicon-checkbox-unchecked:before {
|
|
48
|
+
content: '\f001';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.pamicon-triangle-down:before {
|
|
52
|
+
content: '\f002';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pamicon-checkbox-intermediate:before {
|
|
56
|
+
content: '\f003';
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestio/pam",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Nestio UI modules",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"front-end",
|
|
24
24
|
"elements"
|
|
25
25
|
],
|
|
26
|
-
"author": "
|
|
27
|
-
"license": "
|
|
26
|
+
"author": "Funnel Leasing, Inc.",
|
|
27
|
+
"license": "MIT",
|
|
28
28
|
"bugs": {
|
|
29
29
|
"url": "https://github.com/Nestio/pam/issues"
|
|
30
30
|
},
|
|
@@ -30,19 +30,18 @@ export default function MultiSelect (props){
|
|
|
30
30
|
onClose={props.onClose}
|
|
31
31
|
onOpen={props.onOpen}
|
|
32
32
|
options={props.options}
|
|
33
|
+
optionSets={props.optionSets}
|
|
33
34
|
renderOptionLabel={props.renderOptionLabel}
|
|
34
35
|
renderValueLabel={props.renderValueLabel}
|
|
35
36
|
value={props.value}
|
|
36
37
|
valueAdapter={valueAdapter}
|
|
37
38
|
ValueComponent={props.ValueComponent}
|
|
38
|
-
collapsibleOptions={props.collapsibleOptions}
|
|
39
39
|
/>
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
MultiSelect.propTypes = {
|
|
44
44
|
ariaLabel: PropTypes.string,
|
|
45
|
-
collapsibleOptions: PropTypes.array,
|
|
46
45
|
filterable: PropTypes.bool,
|
|
47
46
|
menuContainerClassName: PropTypes.string,
|
|
48
47
|
menuContainerText: PropTypes.string,
|
|
@@ -52,6 +51,7 @@ MultiSelect.propTypes = {
|
|
|
52
51
|
onClose: PropTypes.func,
|
|
53
52
|
onOpen: PropTypes.func,
|
|
54
53
|
options: PropTypes.array.isRequired,
|
|
54
|
+
optionSets: PropTypes.array,
|
|
55
55
|
renderOptionLabel: PropTypes.func,
|
|
56
56
|
renderValueLabel: PropTypes.func,
|
|
57
57
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
@@ -10,27 +10,11 @@ import styles from './styles/MultiSelectOption.scss';
|
|
|
10
10
|
OptionComponent designed for use in MultiSelects
|
|
11
11
|
*/
|
|
12
12
|
export default function MultiSelectOption (props) {
|
|
13
|
-
const { isSelected, isHighlighted, option
|
|
14
|
-
|
|
15
|
-
function _getCollapsibleClassName(){
|
|
16
|
-
if (currentText) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (collapsibleOptions && collapsibleOptions.length) {
|
|
21
|
-
if (option.collapsedBy && collapsibleOptions.indexOf(option.collapsedBy) > -1) {
|
|
22
|
-
return styles['option__indented'];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
13
|
+
const { isSelected, isHighlighted, option } = props;
|
|
29
14
|
const optionClass = classnames(
|
|
30
15
|
styles.option,
|
|
31
16
|
option.disabled && styles.disabled,
|
|
32
|
-
isHighlighted && styles.highlighted
|
|
33
|
-
_getCollapsibleClassName()
|
|
17
|
+
isHighlighted && styles.highlighted
|
|
34
18
|
);
|
|
35
19
|
|
|
36
20
|
const checkboxClass = classnames({[styles.checked]: isSelected}, {[styles.unchecked]: !isSelected});
|
|
@@ -51,9 +35,7 @@ MultiSelectOption.propTypes = {
|
|
|
51
35
|
isHighlighted: PropTypes.bool.isRequired,
|
|
52
36
|
isSelected: PropTypes.bool.isRequired,
|
|
53
37
|
option: PropTypes.object.isRequired,
|
|
54
|
-
renderOptionLabel: PropTypes.func
|
|
55
|
-
collapsibleOptions: PropTypes.array,
|
|
56
|
-
currentText: PropTypes.string
|
|
38
|
+
renderOptionLabel: PropTypes.func
|
|
57
39
|
};
|
|
58
40
|
|
|
59
41
|
MultiSelectOption.defaultProps = {
|
|
@@ -81,13 +81,13 @@ export default class OptionListSet extends Component {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
renderOptionSet(options, label) {
|
|
84
|
-
const { OptionComponent, EmptyOptionComponent, renderOptionLabel, optionIndex, valueIsSelected, optionSets
|
|
84
|
+
const { OptionComponent, EmptyOptionComponent, renderOptionLabel, optionIndex, valueIsSelected, optionSets } = this.props;
|
|
85
|
+
|
|
85
86
|
let renderedOptions;
|
|
86
87
|
|
|
87
88
|
if (options.length) {
|
|
88
89
|
renderedOptions = options.map((option, index) => {
|
|
89
90
|
index += option.groupIndex || 0;
|
|
90
|
-
|
|
91
91
|
const rendered = (
|
|
92
92
|
<OptionComponent
|
|
93
93
|
id={this.getOptionId(option, index)}
|
|
@@ -97,7 +97,6 @@ export default class OptionListSet extends Component {
|
|
|
97
97
|
isSelected={valueIsSelected(option)}
|
|
98
98
|
renderOptionLabel={renderOptionLabel}
|
|
99
99
|
isHighlighted={index === optionIndex}
|
|
100
|
-
collapsibleState={getCollapsibleState(option.value)}
|
|
101
100
|
{...this.props}
|
|
102
101
|
/>
|
|
103
102
|
);
|
|
@@ -207,7 +206,6 @@ OptionListSet.propTypes = {
|
|
|
207
206
|
OptionComponent
|
|
208
207
|
*/
|
|
209
208
|
renderOptionLabel: PropTypes.func,
|
|
210
|
-
|
|
211
209
|
/**
|
|
212
210
|
Currently highlighted option
|
|
213
211
|
*/
|
|
@@ -216,11 +214,6 @@ OptionListSet.propTypes = {
|
|
|
216
214
|
OptionComponent to be rendered in OptionList
|
|
217
215
|
*/
|
|
218
216
|
OptionComponent: PropTypes.func,
|
|
219
|
-
/**
|
|
220
|
-
Function used to determine if an option is collapsed and can be collapsed
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
getCollapsibleState: PropTypes.func,
|
|
224
217
|
/**
|
|
225
218
|
Function used to determine if individual options are selected
|
|
226
219
|
*/
|
|
@@ -10,8 +10,6 @@ import uniqueId from 'lodash/uniqueId';
|
|
|
10
10
|
|
|
11
11
|
import styles from './styles/SelectCore.scss';
|
|
12
12
|
|
|
13
|
-
import { OPTION_COLLAPSED, OPTION_NOT_COLLAPSED } from '../constants';
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
14
|
The primary Select component which manages the state for the entire select and renders subcomponents. It controls
|
|
17
15
|
whether the dropdown is opened/closed, which option is currently selected, which open has focus, filtering options
|
|
@@ -30,7 +28,6 @@ class SelectCore extends Component {
|
|
|
30
28
|
this.changeValue = this.changeValue.bind(this);
|
|
31
29
|
this.clearValue = this.clearValue.bind(this);
|
|
32
30
|
this.closeMenu = this.closeMenu.bind(this);
|
|
33
|
-
this.getCollapsibleState = this.getCollapsibleState.bind(this);
|
|
34
31
|
this.onBackspace = this.onBackspace.bind(this);
|
|
35
32
|
this.onDown = this.onDown.bind(this);
|
|
36
33
|
this.onEnter = this.onEnter.bind(this);
|
|
@@ -40,7 +37,6 @@ class SelectCore extends Component {
|
|
|
40
37
|
this.onEscape = this.onEscape.bind(this);
|
|
41
38
|
this.openMenu = this.openMenu.bind(this);
|
|
42
39
|
this.setIndex = this.setIndex.bind(this);
|
|
43
|
-
this.toggleCollapsedValue = this.toggleCollapsedValue.bind(this);
|
|
44
40
|
this.toggleValue = this.toggleValue.bind(this);
|
|
45
41
|
this.valueIsSelected = this.valueIsSelected.bind(this);
|
|
46
42
|
|
|
@@ -52,8 +48,7 @@ class SelectCore extends Component {
|
|
|
52
48
|
isOpen: false,
|
|
53
49
|
optionIndex: this._getInitialOptionIndex(props),
|
|
54
50
|
options: props.options || null,
|
|
55
|
-
loading: false
|
|
56
|
-
collapsedOptions: {}
|
|
51
|
+
loading: false
|
|
57
52
|
};
|
|
58
53
|
|
|
59
54
|
this.menuRef = React.createRef();
|
|
@@ -107,16 +102,10 @@ class SelectCore extends Component {
|
|
|
107
102
|
}
|
|
108
103
|
|
|
109
104
|
componentDidUpdate(prevProps, prevState) {
|
|
110
|
-
const { onOptionsFiltered
|
|
111
|
-
|
|
112
|
-
if (prevState.currentText !== this.state.currentText) {
|
|
113
|
-
if (onOptionsFiltered) {
|
|
114
|
-
onOptionsFiltered(this._getFilteredOptions());
|
|
115
|
-
}
|
|
105
|
+
const { onOptionsFiltered } = this.props;
|
|
116
106
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
107
|
+
if (onOptionsFiltered && prevState.currentText !== this.state.currentText) {
|
|
108
|
+
onOptionsFiltered(this._getFilteredOptions());
|
|
120
109
|
}
|
|
121
110
|
}
|
|
122
111
|
|
|
@@ -362,17 +351,6 @@ class SelectCore extends Component {
|
|
|
362
351
|
});
|
|
363
352
|
}
|
|
364
353
|
|
|
365
|
-
toggleCollapsedValue(value){
|
|
366
|
-
this.setState(currentState => {
|
|
367
|
-
const currentCollapsedState = !!currentState.collapsedOptions[value];
|
|
368
|
-
const newValue = Object.assign({}, currentState.collapsedOptions, {[value]: !currentCollapsedState});
|
|
369
|
-
|
|
370
|
-
return {
|
|
371
|
-
collapsedOptions: newValue
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
354
|
// Async functions
|
|
377
355
|
/**
|
|
378
356
|
* This is typically triggered when the select gets passed a new value and is used to populate the select with the
|
|
@@ -422,29 +400,6 @@ class SelectCore extends Component {
|
|
|
422
400
|
return this.props.valueAdapter.valueIsSelected(this.state.currentValue, newValue);
|
|
423
401
|
}
|
|
424
402
|
|
|
425
|
-
getCollapsibleState(value){
|
|
426
|
-
if (!this.props.collapsibleOptions) {
|
|
427
|
-
return null;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (this.state.currentText) {
|
|
431
|
-
return null;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const isCollapsible = this.props.collapsibleOptions.indexOf(value) > -1;
|
|
435
|
-
|
|
436
|
-
if (!isCollapsible) {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (this.state.collapsedOptions[value]) {
|
|
442
|
-
return OPTION_COLLAPSED;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return OPTION_NOT_COLLAPSED;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
403
|
// Private methods and helpers
|
|
449
404
|
/**
|
|
450
405
|
* Returns options filtered by props.filterOption and currentText. Is memoized to reduce repeating same computation
|
|
@@ -460,19 +415,13 @@ class SelectCore extends Component {
|
|
|
460
415
|
return this.state.options;
|
|
461
416
|
}
|
|
462
417
|
|
|
463
|
-
const args = [this.state.options, this.props.filterOption, text
|
|
464
|
-
if (this._cachedArgs && this._cachedArgs.
|
|
418
|
+
const args = [this.state.options, this.props.filterOption, text];
|
|
419
|
+
if (this._cachedArgs && this._cachedArgs[0] == args[0] && this._cachedArgs[1] == args[1] && this._cachedArgs[2] == args[2]) {
|
|
465
420
|
return this._cachedResult;
|
|
466
421
|
}
|
|
467
422
|
|
|
468
423
|
this._cachedArgs = args;
|
|
469
424
|
this._cachedResult = this.state.options.filter((option) => {
|
|
470
|
-
if (!text && option.hasOwnProperty('collapsedBy')) {
|
|
471
|
-
const isHidden = this.getCollapsibleState(option.collapsedBy) === OPTION_COLLAPSED;
|
|
472
|
-
if (isHidden) {
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
425
|
return this.props.filterOption(option, text);
|
|
477
426
|
});
|
|
478
427
|
|
|
@@ -591,7 +540,6 @@ class SelectCore extends Component {
|
|
|
591
540
|
setIndex: this.setIndex,
|
|
592
541
|
shouldShowOptionList: this._shouldShowOptionList(),
|
|
593
542
|
toggleValue: this.toggleValue,
|
|
594
|
-
toggleCollapsedValue: this.toggleCollapsedValue
|
|
595
543
|
});
|
|
596
544
|
}
|
|
597
545
|
|
|
@@ -604,7 +552,6 @@ class SelectCore extends Component {
|
|
|
604
552
|
<MenuComponent
|
|
605
553
|
options={options}
|
|
606
554
|
valueIsSelected={this.valueIsSelected}
|
|
607
|
-
getCollapsibleState={this.getCollapsibleState}
|
|
608
555
|
OptionComponent={OptionComponent}
|
|
609
556
|
renderOptionLabel={renderOptionLabel}
|
|
610
557
|
onUp={this.onUp}
|
|
@@ -679,6 +626,11 @@ SelectCore.propTypes = {
|
|
|
679
626
|
*/
|
|
680
627
|
filterOption: PropTypes.func,
|
|
681
628
|
/**
|
|
629
|
+
Function intercepts input value change
|
|
630
|
+
* @param {string} str
|
|
631
|
+
*/
|
|
632
|
+
handleValueChange: PropTypes.func,
|
|
633
|
+
/**
|
|
682
634
|
Function used to fetch async options. Is invoked with currentText and should return a promise with the options
|
|
683
635
|
* @param {string} str
|
|
684
636
|
* @returns {Promise}
|
|
@@ -781,9 +733,6 @@ SelectCore.propTypes = {
|
|
|
781
733
|
disabled: PropTypes.bool,
|
|
782
734
|
filterable: PropTypes.bool,
|
|
783
735
|
onOptionsFiltered: PropTypes.func,
|
|
784
|
-
onChangeText: PropTypes.func,
|
|
785
|
-
collapsibleOptions: PropTypes.array
|
|
786
|
-
|
|
787
736
|
};
|
|
788
737
|
|
|
789
738
|
SelectCore.defaultProps = {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import cn from 'classnames';
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
1
|
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
5
3
|
|
|
6
|
-
import
|
|
4
|
+
import isEqual from 'lodash/isEqual';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Generic component for rendering an option in a select. Contains functionality for handling clicking and focusing.
|
|
@@ -13,13 +11,12 @@ export default class SelectOption extends Component {
|
|
|
13
11
|
super();
|
|
14
12
|
this.onClick = this.onClick.bind(this);
|
|
15
13
|
this.onMouseEnter = this.onMouseEnter.bind(this);
|
|
16
|
-
this.onCollapseClick = this.onCollapseClick.bind(this);
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
shouldComponentUpdate(nextProps) {
|
|
20
17
|
// check only interesting props
|
|
21
18
|
const currentProps = this.props;
|
|
22
|
-
const propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted'
|
|
19
|
+
const propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted'];
|
|
23
20
|
|
|
24
21
|
return propsToCheck
|
|
25
22
|
.map((val) => isEqual( currentProps[val], nextProps[val]) )
|
|
@@ -45,32 +42,19 @@ export default class SelectOption extends Component {
|
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
onCollapseClick(e){
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
51
|
-
const { toggleCollapsedValue, option } = this.props;
|
|
52
|
-
toggleCollapsedValue(option.value);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
45
|
render() {
|
|
56
|
-
const { isSelected, option, id, className, collapsibleState, renderOptionLabel } = this.props;
|
|
57
|
-
|
|
58
46
|
return (
|
|
59
47
|
<li
|
|
60
|
-
aria-selected={isSelected}
|
|
61
|
-
aria-disabled={option.disabled}
|
|
62
|
-
aria-label={renderOptionLabel(this.props.option)}
|
|
63
|
-
className={
|
|
64
|
-
id={id}
|
|
48
|
+
aria-selected={this.props.isSelected}
|
|
49
|
+
aria-disabled={this.props.option.disabled}
|
|
50
|
+
aria-label={this.props.renderOptionLabel(this.props.option)}
|
|
51
|
+
className={this.props.className}
|
|
52
|
+
id={this.props.id}
|
|
65
53
|
onClick={this.onClick}
|
|
66
54
|
onMouseEnter={this.onMouseEnter}
|
|
67
55
|
role="option"
|
|
68
56
|
tabIndex="-1"
|
|
69
57
|
>
|
|
70
|
-
{
|
|
71
|
-
collapsibleState &&
|
|
72
|
-
<Collapse collapsibleState={collapsibleState} onClick={this.onCollapseClick} />
|
|
73
|
-
}
|
|
74
58
|
{ this.props.children }
|
|
75
59
|
</li>
|
|
76
60
|
);
|
|
@@ -89,7 +73,4 @@ SelectOption.propTypes = {
|
|
|
89
73
|
toggleValue: PropTypes.func.isRequired,
|
|
90
74
|
unselectOnClick: PropTypes.bool,
|
|
91
75
|
id: PropTypes.string,
|
|
92
|
-
toggleCollapsedValue: PropTypes.func.isRequired,
|
|
93
|
-
collapsibleState: PropTypes.string,
|
|
94
|
-
currentText: PropTypes.string
|
|
95
76
|
};
|
|
@@ -40,7 +40,6 @@ export default function SingleSelect (props){
|
|
|
40
40
|
onClose={props.onClose}
|
|
41
41
|
options={props.options}
|
|
42
42
|
optionSets={props.optionSets}
|
|
43
|
-
onChangeText={props.onChangeText}
|
|
44
43
|
placeholder={props.placeholder}
|
|
45
44
|
renderValueLabel={props.renderValueLabel}
|
|
46
45
|
renderOptionLabel={props.renderOptionLabel}
|
|
@@ -64,7 +63,6 @@ SingleSelect.propTypes = {
|
|
|
64
63
|
onChange: PropTypes.func,
|
|
65
64
|
onClose: PropTypes.func,
|
|
66
65
|
onOpen: PropTypes.func,
|
|
67
|
-
onChangeText: PropTypes.func,
|
|
68
66
|
OptionComponent: PropTypes.func,
|
|
69
67
|
renderOptionLabel: PropTypes.func,
|
|
70
68
|
renderValueLabel: PropTypes.func,
|
|
@@ -22,7 +22,6 @@ export default function TagBoxMenuSelect (props) {
|
|
|
22
22
|
closeOnSelect={false}
|
|
23
23
|
|
|
24
24
|
ariaLabel={props.ariaLabel}
|
|
25
|
-
collapsibleOptions={props.collapsibleOptions}
|
|
26
25
|
filterable={props.filterable}
|
|
27
26
|
disabled={props.disabled}
|
|
28
27
|
onChange={props.onChange}
|
|
@@ -40,7 +39,6 @@ export default function TagBoxMenuSelect (props) {
|
|
|
40
39
|
|
|
41
40
|
TagBoxMenuSelect.propTypes = {
|
|
42
41
|
ariaLabel: PropTypes.string,
|
|
43
|
-
collapsibleOptions: PropTypes.array,
|
|
44
42
|
filterable: PropTypes.bool,
|
|
45
43
|
disabled: PropTypes.bool,
|
|
46
44
|
options: PropTypes.array.isRequired,
|
|
@@ -14,6 +14,7 @@ const defaultProps = {
|
|
|
14
14
|
onOpen: () => {},
|
|
15
15
|
onClose: () => {},
|
|
16
16
|
options: [],
|
|
17
|
+
optionSets: [],
|
|
17
18
|
renderOptionLabel: () => {},
|
|
18
19
|
renderValueLabel: () => {}
|
|
19
20
|
};
|
|
@@ -30,6 +31,7 @@ test('it passes on correct props', () => {
|
|
|
30
31
|
expect(selectCore.prop('onOpen')).toEqual(props.onOpen);
|
|
31
32
|
expect(selectCore.prop('onClose')).toEqual(props.onClose);
|
|
32
33
|
expect(selectCore.prop('options')).toEqual(props.options);
|
|
34
|
+
expect(selectCore.prop('optionSets')).toEqual(props.optionSets);
|
|
33
35
|
expect(selectCore.prop('renderOptionLabel')).toEqual(props.renderOptionLabel);
|
|
34
36
|
expect(selectCore.prop('renderValueLabel')).toEqual(props.renderValueLabel);
|
|
35
37
|
expect(selectCore.prop('ValueComponent')).toEqual(props.ValueComponent);
|
|
@@ -16,10 +16,7 @@ const getDefaultProps = () => ({
|
|
|
16
16
|
toggleValue: sinon.spy(),
|
|
17
17
|
option: {value: 1, label: 'one'},
|
|
18
18
|
index: 0,
|
|
19
|
-
setIndex: sinon.spy()
|
|
20
|
-
toggleCollapsedValue: jest.fn(),
|
|
21
|
-
collapsibleOptions: null,
|
|
22
|
-
currentText: ''
|
|
19
|
+
setIndex: sinon.spy()
|
|
23
20
|
});
|
|
24
21
|
|
|
25
22
|
test('it renders checkbox based on isSelected', () => {
|
|
@@ -48,7 +45,7 @@ test('it renders custom label if passed in', () => {
|
|
|
48
45
|
expect(wrapper.findWhere(whereClassName(styles.label)).text()).toEqual(label);
|
|
49
46
|
});
|
|
50
47
|
|
|
51
|
-
test('it
|
|
48
|
+
test('it pases classes to SelectOption based on props', () => {
|
|
52
49
|
const props = getDefaultProps();
|
|
53
50
|
const wrapper = shallow(<MultiSelectOption {...props} />);
|
|
54
51
|
expect(wrapper.find(SelectOption).prop('className')).toEqual(styles['option']);
|
|
@@ -61,40 +58,3 @@ test('it passes classes to SelectOption based on props', () => {
|
|
|
61
58
|
classnames(styles.option, styles.disabled, styles.highlighted)
|
|
62
59
|
);
|
|
63
60
|
});
|
|
64
|
-
|
|
65
|
-
describe('collapsibleOption classname', function(){
|
|
66
|
-
it('renders indented class when option has collapsedBy is a part of collapsibleOption', function(){
|
|
67
|
-
const props = getDefaultProps();
|
|
68
|
-
const wrapper = shallow(<MultiSelectOption {...props} />);
|
|
69
|
-
|
|
70
|
-
// no collapsedOptions and no collapsible -> no class
|
|
71
|
-
expect(wrapper.find(SelectOption).prop('className').includes(styles['option__indented'])).toBe(false);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// collapsedOptions set but no collapsible -> no class
|
|
75
|
-
wrapper.setProps({collapsibleOptions: [3, 4]});
|
|
76
|
-
expect(wrapper.find(SelectOption).prop('className').includes(styles['option__indented'])).toBe(false);
|
|
77
|
-
|
|
78
|
-
// collapsedOptions set and collapsedBy -> has class
|
|
79
|
-
wrapper.setProps({
|
|
80
|
-
option: { value: 1, label: 'One', collapsedBy: 3}
|
|
81
|
-
});
|
|
82
|
-
expect(wrapper.find(SelectOption).prop('className').includes(styles['option__indented'])).toBe(true);
|
|
83
|
-
|
|
84
|
-
// collapsedOptions set and collapsedBy, but options are filtered -> no class
|
|
85
|
-
wrapper.setProps({
|
|
86
|
-
currentText: 'asdf'
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// collapsedOptions set but doesnt match collapsedBy -> no class
|
|
90
|
-
wrapper.setProps({
|
|
91
|
-
currentText: '',
|
|
92
|
-
option: { value: 1, label: 'One', collapsedBy: 6}
|
|
93
|
-
});
|
|
94
|
-
expect(wrapper.find(SelectOption).prop('className').includes(styles['option__indented'])).toBe(false);
|
|
95
|
-
|
|
96
|
-
// collapsedOptions empty -> no class
|
|
97
|
-
wrapper.setProps({collapsibleOptions: []});
|
|
98
|
-
expect(wrapper.find(SelectOption).prop('className').includes(styles['option__indented'])).toBe(false);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -7,7 +7,6 @@ import SingleSelectOption from '../SingleSelectOption';
|
|
|
7
7
|
import BasicMinLengthComponent from '../BasicMinLengthComponent';
|
|
8
8
|
import BasicEmptyOptionComponent from '../BasicEmptyOptionComponent';
|
|
9
9
|
import KEYS from '../../utils/keys';
|
|
10
|
-
import { OPTION_COLLAPSED, OPTION_NOT_COLLAPSED } from '../../constants';
|
|
11
10
|
|
|
12
11
|
let defaultProps;
|
|
13
12
|
|
|
@@ -25,9 +24,7 @@ beforeEach(function(){
|
|
|
25
24
|
toggleValue: jest.fn(),
|
|
26
25
|
setIndex: jest.fn(),
|
|
27
26
|
reference: React.createRef(),
|
|
28
|
-
menuId: 'menu-1'
|
|
29
|
-
getCollapsibleState: () => null,
|
|
30
|
-
toggleCollapsedValue: jest.fn()
|
|
27
|
+
menuId: 'menu-1'
|
|
31
28
|
};
|
|
32
29
|
});
|
|
33
30
|
|
|
@@ -193,23 +190,3 @@ describe('move scrollbar position', function() {
|
|
|
193
190
|
|
|
194
191
|
});
|
|
195
192
|
|
|
196
|
-
|
|
197
|
-
describe('collapsibleState', function(){
|
|
198
|
-
it('calls getCollapsibleState with the options and passes the result to the components', function(){
|
|
199
|
-
const getCollapsibleState = jest.fn().mockImplementation((value) => {
|
|
200
|
-
return value % 2 == 0 ? OPTION_COLLAPSED : OPTION_NOT_COLLAPSED;
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const wrapper = mount(<OptionListSet {...defaultProps} getCollapsibleState={getCollapsibleState}/>);
|
|
204
|
-
expect(getCollapsibleState).toHaveBeenCalledTimes(2);
|
|
205
|
-
expect(getCollapsibleState).toHaveBeenCalledWith(basicOptions[0].value);
|
|
206
|
-
expect(getCollapsibleState).toHaveBeenCalledWith(basicOptions[1].value);
|
|
207
|
-
|
|
208
|
-
expect(
|
|
209
|
-
wrapper.find(SingleSelectOption).at(0).prop('collapsibleState')
|
|
210
|
-
).toEqual(OPTION_NOT_COLLAPSED);
|
|
211
|
-
expect(
|
|
212
|
-
wrapper.find(SingleSelectOption).at(1).prop('collapsibleState')
|
|
213
|
-
).toEqual(OPTION_COLLAPSED);
|
|
214
|
-
});
|
|
215
|
-
});
|