@nestio/pam 2.0.6 → 2.0.7
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/examples/components/Select.jsx +26 -0
- package/examples/index.html +5 -0
- package/lib/components/Collapse.js +50 -0
- package/lib/components/MultiSelect.js +3 -1
- package/lib/components/MultiSelectOption.js +22 -3
- package/lib/components/OptionListSet.js +11 -3
- package/lib/components/SelectCore.js +84 -26
- package/lib/components/SelectOption.js +44 -11
- package/lib/components/SingleSelect.js +2 -0
- package/lib/components/TagBoxMenuSelect.js +2 -0
- package/lib/components/styles/MultiSelectOption.scss +4 -0
- package/lib/components/styles/SelectOption.scss +12 -0
- package/lib/components/styles/_variables.scss +1 -0
- package/lib/components/styles/icons/icons.css +1 -57
- package/lib/constants.js +7 -0
- package/package.json +1 -1
- package/src/components/Collapse.jsx +30 -0
- package/src/components/MultiSelect.jsx +2 -0
- package/src/components/MultiSelectOption.jsx +21 -3
- package/src/components/OptionListSet.jsx +9 -2
- package/src/components/SelectCore.jsx +62 -11
- package/src/components/SelectOption.jsx +27 -8
- package/src/components/SingleSelect.jsx +2 -0
- package/src/components/TagBoxMenuSelect.jsx +2 -0
- package/src/components/__tests__/Collapse.spec.js +26 -0
- package/src/components/__tests__/MultiSelectOption.spec.js +42 -2
- package/src/components/__tests__/OptionListSet.spec.js +24 -1
- package/src/components/__tests__/SelectCore.spec.js +103 -0
- package/src/components/__tests__/SelectOption.spec.js +33 -2
- package/src/components/__tests__/SingleSelectOption.spec.js +2 -1
- package/src/components/styles/MultiSelectOption.scss +4 -0
- package/src/components/styles/SelectOption.scss +12 -0
- package/src/components/styles/_variables.scss +1 -0
- package/src/components/styles/icons/icons.css +1 -57
- package/src/constants.js +2 -0
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/inspectionProfiles/profiles_settings.xml +0 -6
- package/.idea/misc.xml +0 -4
- package/.idea/modules.xml +0 -8
- package/.idea/pam.iml +0 -15
- package/.idea/vcs.xml +0 -6
- 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/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
|
@@ -32,6 +32,20 @@ const hugeOptions = Object.keys(window).map((val, idx) => {
|
|
|
32
32
|
return { value: idx, label: val };
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
const customClassNameOptions = [
|
|
36
|
+
{ value: 'red', label: 'Cool Color', optionClassName: 'cool-color' },
|
|
37
|
+
{ value: 'blue', label: 'Boring Color' },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const collapsibleOptions = [
|
|
41
|
+
{value: 1, label: 'One'},
|
|
42
|
+
{value: 2, label: 'Two', collapsedBy: 1 },
|
|
43
|
+
{value: 3, label: 'Three'},
|
|
44
|
+
{value: 4, label: 'Four', collapsedBy: 3},
|
|
45
|
+
{value: 5, label: 'Five', collapsedBy: 3},
|
|
46
|
+
{value: 6, label: 'Six', collapsedBy: null},
|
|
47
|
+
];
|
|
48
|
+
|
|
35
49
|
const Circle = (props) => (
|
|
36
50
|
<div style={{
|
|
37
51
|
display: 'inline-block',
|
|
@@ -131,6 +145,7 @@ export default function SelectPage () {
|
|
|
131
145
|
options={basicOptions}
|
|
132
146
|
value="1"
|
|
133
147
|
filterable={true}
|
|
148
|
+
onChangeText={(t) => console.log(t)}
|
|
134
149
|
/>
|
|
135
150
|
</ExamplePanel>
|
|
136
151
|
<ExamplePanel title="Custom Option Select">
|
|
@@ -210,6 +225,17 @@ export default function SelectPage () {
|
|
|
210
225
|
<ExamplePanel title="Programmatic Manipulation">
|
|
211
226
|
<Container />
|
|
212
227
|
</ExamplePanel>
|
|
228
|
+
<ExamplePanel title="Custom Option Classname">
|
|
229
|
+
<MultiSelect
|
|
230
|
+
options={customClassNameOptions}
|
|
231
|
+
/>
|
|
232
|
+
</ExamplePanel>
|
|
233
|
+
<ExamplePanel title="Collapsible Multiselect">
|
|
234
|
+
<TagBoxMenuSelect
|
|
235
|
+
options={collapsibleOptions}
|
|
236
|
+
collapsibleOptions={[1, 3]}
|
|
237
|
+
/>
|
|
238
|
+
</ExamplePanel>
|
|
213
239
|
</Page>
|
|
214
240
|
);
|
|
215
241
|
}
|
package/examples/index.html
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Collapse;
|
|
7
|
+
|
|
8
|
+
var _classnames = require('classnames');
|
|
9
|
+
|
|
10
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
11
|
+
|
|
12
|
+
var _propTypes = require('prop-types');
|
|
13
|
+
|
|
14
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
15
|
+
|
|
16
|
+
var _react = require('react');
|
|
17
|
+
|
|
18
|
+
var _react2 = _interopRequireDefault(_react);
|
|
19
|
+
|
|
20
|
+
var _constants = require('../constants');
|
|
21
|
+
|
|
22
|
+
var _icons = require('./styles/icons/icons.css');
|
|
23
|
+
|
|
24
|
+
var _icons2 = _interopRequireDefault(_icons);
|
|
25
|
+
|
|
26
|
+
var _SelectOption = require('./styles/SelectOption.scss');
|
|
27
|
+
|
|
28
|
+
var _SelectOption2 = _interopRequireDefault(_SelectOption);
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
function Collapse(_ref) {
|
|
33
|
+
var onClick = _ref.onClick,
|
|
34
|
+
collapsibleState = _ref.collapsibleState;
|
|
35
|
+
|
|
36
|
+
return _react2.default.createElement(
|
|
37
|
+
'span',
|
|
38
|
+
{
|
|
39
|
+
onClick: onClick,
|
|
40
|
+
className: _SelectOption2.default['collapse'],
|
|
41
|
+
role: 'button'
|
|
42
|
+
},
|
|
43
|
+
_react2.default.createElement('i', { className: (0, _classnames2.default)(_icons2.default.pamicon, collapsibleState == _constants.OPTION_COLLAPSED ? _icons2.default['pamicon-triangle-right'] : _icons2.default['pamicon-triangle-down'], _SelectOption2.default['collapse-icon']) })
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Collapse.propTypes = {
|
|
48
|
+
onClick: _propTypes2.default.func,
|
|
49
|
+
collapsibleState: _propTypes2.default.string
|
|
50
|
+
};
|
|
@@ -62,12 +62,14 @@ function MultiSelect(props) {
|
|
|
62
62
|
renderValueLabel: props.renderValueLabel,
|
|
63
63
|
value: props.value,
|
|
64
64
|
valueAdapter: valueAdapter,
|
|
65
|
-
ValueComponent: props.ValueComponent
|
|
65
|
+
ValueComponent: props.ValueComponent,
|
|
66
|
+
collapsibleOptions: props.collapsibleOptions
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
MultiSelect.propTypes = {
|
|
70
71
|
ariaLabel: _propTypes2.default.string,
|
|
72
|
+
collapsibleOptions: _propTypes2.default.array,
|
|
71
73
|
filterable: _propTypes2.default.bool,
|
|
72
74
|
menuContainerClassName: _propTypes2.default.string,
|
|
73
75
|
menuContainerText: _propTypes2.default.string,
|
|
@@ -38,9 +38,26 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
38
38
|
function MultiSelectOption(props) {
|
|
39
39
|
var isSelected = props.isSelected,
|
|
40
40
|
isHighlighted = props.isHighlighted,
|
|
41
|
-
option = props.option
|
|
41
|
+
option = props.option,
|
|
42
|
+
currentText = props.currentText,
|
|
43
|
+
collapsibleOptions = props.collapsibleOptions;
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
|
|
46
|
+
function _getCollapsibleClassName() {
|
|
47
|
+
if (currentText) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (collapsibleOptions && collapsibleOptions.length) {
|
|
52
|
+
if (option.collapsedBy && collapsibleOptions.indexOf(option.collapsedBy) > -1) {
|
|
53
|
+
return _MultiSelectOption2.default['option__indented'];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var optionClass = (0, _classnames4.default)(_MultiSelectOption2.default.option, option.disabled && _MultiSelectOption2.default.disabled, isHighlighted && _MultiSelectOption2.default.highlighted, _getCollapsibleClassName());
|
|
44
61
|
|
|
45
62
|
var checkboxClass = (0, _classnames4.default)(_defineProperty({}, _MultiSelectOption2.default.checked, isSelected), _defineProperty({}, _MultiSelectOption2.default.unchecked, !isSelected));
|
|
46
63
|
var label = props.renderOptionLabel(props.option);
|
|
@@ -66,7 +83,9 @@ MultiSelectOption.propTypes = {
|
|
|
66
83
|
isHighlighted: _propTypes2.default.bool.isRequired,
|
|
67
84
|
isSelected: _propTypes2.default.bool.isRequired,
|
|
68
85
|
option: _propTypes2.default.object.isRequired,
|
|
69
|
-
renderOptionLabel: _propTypes2.default.func
|
|
86
|
+
renderOptionLabel: _propTypes2.default.func,
|
|
87
|
+
collapsibleOptions: _propTypes2.default.array,
|
|
88
|
+
currentText: _propTypes2.default.string
|
|
70
89
|
};
|
|
71
90
|
|
|
72
91
|
MultiSelectOption.defaultProps = {
|
|
@@ -150,14 +150,15 @@ var OptionListSet = function (_Component) {
|
|
|
150
150
|
renderOptionLabel = _props.renderOptionLabel,
|
|
151
151
|
optionIndex = _props.optionIndex,
|
|
152
152
|
valueIsSelected = _props.valueIsSelected,
|
|
153
|
-
optionSets = _props.optionSets
|
|
154
|
-
|
|
153
|
+
optionSets = _props.optionSets,
|
|
154
|
+
getCollapsibleState = _props.getCollapsibleState;
|
|
155
155
|
|
|
156
156
|
var renderedOptions = void 0;
|
|
157
157
|
|
|
158
158
|
if (options.length) {
|
|
159
159
|
renderedOptions = options.map(function (option, index) {
|
|
160
160
|
index += option.groupIndex || 0;
|
|
161
|
+
|
|
161
162
|
var rendered = _react2.default.createElement(OptionComponent, _extends({
|
|
162
163
|
id: _this3.getOptionId(option, index),
|
|
163
164
|
key: option.value,
|
|
@@ -165,7 +166,8 @@ var OptionListSet = function (_Component) {
|
|
|
165
166
|
index: index,
|
|
166
167
|
isSelected: valueIsSelected(option),
|
|
167
168
|
renderOptionLabel: renderOptionLabel,
|
|
168
|
-
isHighlighted: index === optionIndex
|
|
169
|
+
isHighlighted: index === optionIndex,
|
|
170
|
+
collapsibleState: getCollapsibleState(option.value)
|
|
169
171
|
}, _this3.props));
|
|
170
172
|
return rendered;
|
|
171
173
|
});
|
|
@@ -283,6 +285,7 @@ OptionListSet.propTypes = {
|
|
|
283
285
|
OptionComponent
|
|
284
286
|
*/
|
|
285
287
|
renderOptionLabel: _propTypes2.default.func,
|
|
288
|
+
|
|
286
289
|
/**
|
|
287
290
|
Currently highlighted option
|
|
288
291
|
*/
|
|
@@ -291,6 +294,11 @@ OptionListSet.propTypes = {
|
|
|
291
294
|
OptionComponent to be rendered in OptionList
|
|
292
295
|
*/
|
|
293
296
|
OptionComponent: _propTypes2.default.func,
|
|
297
|
+
/**
|
|
298
|
+
Function used to determine if an option is collapsed and can be collapsed
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
getCollapsibleState: _propTypes2.default.func,
|
|
294
302
|
/**
|
|
295
303
|
Function used to determine if individual options are selected
|
|
296
304
|
*/
|
|
@@ -45,8 +45,12 @@ var _SelectCore = require('./styles/SelectCore.scss');
|
|
|
45
45
|
|
|
46
46
|
var _SelectCore2 = _interopRequireDefault(_SelectCore);
|
|
47
47
|
|
|
48
|
+
var _constants = require('../constants');
|
|
49
|
+
|
|
48
50
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
51
|
|
|
52
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
53
|
+
|
|
50
54
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
51
55
|
|
|
52
56
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
@@ -75,6 +79,7 @@ var SelectCore = function (_Component) {
|
|
|
75
79
|
_this.changeValue = _this.changeValue.bind(_this);
|
|
76
80
|
_this.clearValue = _this.clearValue.bind(_this);
|
|
77
81
|
_this.closeMenu = _this.closeMenu.bind(_this);
|
|
82
|
+
_this.getCollapsibleState = _this.getCollapsibleState.bind(_this);
|
|
78
83
|
_this.onBackspace = _this.onBackspace.bind(_this);
|
|
79
84
|
_this.onDown = _this.onDown.bind(_this);
|
|
80
85
|
_this.onEnter = _this.onEnter.bind(_this);
|
|
@@ -84,6 +89,7 @@ var SelectCore = function (_Component) {
|
|
|
84
89
|
_this.onEscape = _this.onEscape.bind(_this);
|
|
85
90
|
_this.openMenu = _this.openMenu.bind(_this);
|
|
86
91
|
_this.setIndex = _this.setIndex.bind(_this);
|
|
92
|
+
_this.toggleCollapsedValue = _this.toggleCollapsedValue.bind(_this);
|
|
87
93
|
_this.toggleValue = _this.toggleValue.bind(_this);
|
|
88
94
|
_this.valueIsSelected = _this.valueIsSelected.bind(_this);
|
|
89
95
|
|
|
@@ -95,7 +101,8 @@ var SelectCore = function (_Component) {
|
|
|
95
101
|
isOpen: false,
|
|
96
102
|
optionIndex: _this._getInitialOptionIndex(props),
|
|
97
103
|
options: props.options || null,
|
|
98
|
-
loading: false
|
|
104
|
+
loading: false,
|
|
105
|
+
collapsedOptions: {}
|
|
99
106
|
};
|
|
100
107
|
|
|
101
108
|
_this.menuRef = _react2.default.createRef();
|
|
@@ -166,11 +173,19 @@ var SelectCore = function (_Component) {
|
|
|
166
173
|
}, {
|
|
167
174
|
key: 'componentDidUpdate',
|
|
168
175
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
169
|
-
var
|
|
176
|
+
var _props2 = this.props,
|
|
177
|
+
onOptionsFiltered = _props2.onOptionsFiltered,
|
|
178
|
+
onChangeText = _props2.onChangeText;
|
|
170
179
|
|
|
171
180
|
|
|
172
|
-
if (
|
|
173
|
-
onOptionsFiltered
|
|
181
|
+
if (prevState.currentText !== this.state.currentText) {
|
|
182
|
+
if (onOptionsFiltered) {
|
|
183
|
+
onOptionsFiltered(this._getFilteredOptions());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (onChangeText) {
|
|
187
|
+
onChangeText(this.state.currentText);
|
|
188
|
+
}
|
|
174
189
|
}
|
|
175
190
|
}
|
|
176
191
|
|
|
@@ -196,10 +211,10 @@ var SelectCore = function (_Component) {
|
|
|
196
211
|
}, {
|
|
197
212
|
key: 'closeMenu',
|
|
198
213
|
value: function closeMenu() {
|
|
199
|
-
var
|
|
200
|
-
alwaysOpen =
|
|
201
|
-
disableOnClickOutside =
|
|
202
|
-
onClose =
|
|
214
|
+
var _props3 = this.props,
|
|
215
|
+
alwaysOpen = _props3.alwaysOpen,
|
|
216
|
+
disableOnClickOutside = _props3.disableOnClickOutside,
|
|
217
|
+
onClose = _props3.onClose;
|
|
203
218
|
|
|
204
219
|
|
|
205
220
|
if (alwaysOpen) return;
|
|
@@ -223,11 +238,11 @@ var SelectCore = function (_Component) {
|
|
|
223
238
|
value: function openMenu() {
|
|
224
239
|
var _this2 = this;
|
|
225
240
|
|
|
226
|
-
var
|
|
227
|
-
alwaysOpen =
|
|
228
|
-
enableOnClickOutside =
|
|
229
|
-
onOpen =
|
|
230
|
-
disabled =
|
|
241
|
+
var _props4 = this.props,
|
|
242
|
+
alwaysOpen = _props4.alwaysOpen,
|
|
243
|
+
enableOnClickOutside = _props4.enableOnClickOutside,
|
|
244
|
+
onOpen = _props4.onOpen,
|
|
245
|
+
disabled = _props4.disabled;
|
|
231
246
|
|
|
232
247
|
|
|
233
248
|
if (disabled) return;
|
|
@@ -480,6 +495,18 @@ var SelectCore = function (_Component) {
|
|
|
480
495
|
}
|
|
481
496
|
});
|
|
482
497
|
}
|
|
498
|
+
}, {
|
|
499
|
+
key: 'toggleCollapsedValue',
|
|
500
|
+
value: function toggleCollapsedValue(value) {
|
|
501
|
+
this.setState(function (currentState) {
|
|
502
|
+
var currentCollapsedState = !!currentState.collapsedOptions[value];
|
|
503
|
+
var newValue = Object.assign({}, currentState.collapsedOptions, _defineProperty({}, value, !currentCollapsedState));
|
|
504
|
+
|
|
505
|
+
return {
|
|
506
|
+
collapsedOptions: newValue
|
|
507
|
+
};
|
|
508
|
+
});
|
|
509
|
+
}
|
|
483
510
|
|
|
484
511
|
// Async functions
|
|
485
512
|
/**
|
|
@@ -542,6 +569,29 @@ var SelectCore = function (_Component) {
|
|
|
542
569
|
value: function valueIsSelected(newValue) {
|
|
543
570
|
return this.props.valueAdapter.valueIsSelected(this.state.currentValue, newValue);
|
|
544
571
|
}
|
|
572
|
+
}, {
|
|
573
|
+
key: 'getCollapsibleState',
|
|
574
|
+
value: function getCollapsibleState(value) {
|
|
575
|
+
if (!this.props.collapsibleOptions) {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (this.state.currentText) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
var isCollapsible = this.props.collapsibleOptions.indexOf(value) > -1;
|
|
584
|
+
|
|
585
|
+
if (!isCollapsible) {
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (this.state.collapsedOptions[value]) {
|
|
590
|
+
return _constants.OPTION_COLLAPSED;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return _constants.OPTION_NOT_COLLAPSED;
|
|
594
|
+
}
|
|
545
595
|
|
|
546
596
|
// Private methods and helpers
|
|
547
597
|
/**
|
|
@@ -563,13 +613,21 @@ var SelectCore = function (_Component) {
|
|
|
563
613
|
return this.state.options;
|
|
564
614
|
}
|
|
565
615
|
|
|
566
|
-
var args = [this.state.options, this.props.filterOption, text];
|
|
567
|
-
if (this._cachedArgs && this._cachedArgs
|
|
616
|
+
var args = [this.state.options, this.props.filterOption, text, this.state.collapsedOptions];
|
|
617
|
+
if (this._cachedArgs && this._cachedArgs.every(function (arg, i) {
|
|
618
|
+
return args[i] === arg;
|
|
619
|
+
})) {
|
|
568
620
|
return this._cachedResult;
|
|
569
621
|
}
|
|
570
622
|
|
|
571
623
|
this._cachedArgs = args;
|
|
572
624
|
this._cachedResult = this.state.options.filter(function (option) {
|
|
625
|
+
if (!text && option.hasOwnProperty('collapsedBy')) {
|
|
626
|
+
var isHidden = _this7.getCollapsibleState(option.collapsedBy) === _constants.OPTION_COLLAPSED;
|
|
627
|
+
if (isHidden) {
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
573
631
|
return _this7.props.filterOption(option, text);
|
|
574
632
|
});
|
|
575
633
|
|
|
@@ -703,16 +761,17 @@ var SelectCore = function (_Component) {
|
|
|
703
761
|
optionIndex: this.state.optionIndex,
|
|
704
762
|
setIndex: this.setIndex,
|
|
705
763
|
shouldShowOptionList: this._shouldShowOptionList(),
|
|
706
|
-
toggleValue: this.toggleValue
|
|
764
|
+
toggleValue: this.toggleValue,
|
|
765
|
+
toggleCollapsedValue: this.toggleCollapsedValue
|
|
707
766
|
});
|
|
708
767
|
}
|
|
709
768
|
}, {
|
|
710
769
|
key: 'renderMenu',
|
|
711
770
|
value: function renderMenu() {
|
|
712
|
-
var
|
|
713
|
-
MenuComponent =
|
|
714
|
-
OptionComponent =
|
|
715
|
-
renderOptionLabel =
|
|
771
|
+
var _props5 = this.props,
|
|
772
|
+
MenuComponent = _props5.MenuComponent,
|
|
773
|
+
OptionComponent = _props5.OptionComponent,
|
|
774
|
+
renderOptionLabel = _props5.renderOptionLabel;
|
|
716
775
|
|
|
717
776
|
var options = this._getFilteredOptions();
|
|
718
777
|
var props = this.generateChildProps();
|
|
@@ -720,6 +779,7 @@ var SelectCore = function (_Component) {
|
|
|
720
779
|
return _react2.default.createElement(MenuComponent, _extends({
|
|
721
780
|
options: options,
|
|
722
781
|
valueIsSelected: this.valueIsSelected,
|
|
782
|
+
getCollapsibleState: this.getCollapsibleState,
|
|
723
783
|
OptionComponent: OptionComponent,
|
|
724
784
|
renderOptionLabel: renderOptionLabel,
|
|
725
785
|
onUp: this.onUp,
|
|
@@ -795,11 +855,6 @@ SelectCore.propTypes = {
|
|
|
795
855
|
*/
|
|
796
856
|
filterOption: _propTypes2.default.func,
|
|
797
857
|
/**
|
|
798
|
-
Function intercepts input value change
|
|
799
|
-
* @param {string} str
|
|
800
|
-
*/
|
|
801
|
-
handleValueChange: _propTypes2.default.func,
|
|
802
|
-
/**
|
|
803
858
|
Function used to fetch async options. Is invoked with currentText and should return a promise with the options
|
|
804
859
|
* @param {string} str
|
|
805
860
|
* @returns {Promise}
|
|
@@ -901,7 +956,10 @@ SelectCore.propTypes = {
|
|
|
901
956
|
disableOnClickOutside: _propTypes2.default.func,
|
|
902
957
|
disabled: _propTypes2.default.bool,
|
|
903
958
|
filterable: _propTypes2.default.bool,
|
|
904
|
-
onOptionsFiltered: _propTypes2.default.func
|
|
959
|
+
onOptionsFiltered: _propTypes2.default.func,
|
|
960
|
+
onChangeText: _propTypes2.default.func,
|
|
961
|
+
collapsibleOptions: _propTypes2.default.array
|
|
962
|
+
|
|
905
963
|
};
|
|
906
964
|
|
|
907
965
|
SelectCore.defaultProps = {
|
|
@@ -6,17 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _classnames = require('classnames');
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
12
|
+
|
|
13
|
+
var _isEqual = require('lodash/isEqual');
|
|
14
|
+
|
|
15
|
+
var _isEqual2 = _interopRequireDefault(_isEqual);
|
|
12
16
|
|
|
13
17
|
var _propTypes = require('prop-types');
|
|
14
18
|
|
|
15
19
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
16
20
|
|
|
17
|
-
var
|
|
21
|
+
var _react = require('react');
|
|
18
22
|
|
|
19
|
-
var
|
|
23
|
+
var _react2 = _interopRequireDefault(_react);
|
|
24
|
+
|
|
25
|
+
var _Collapse = require('./Collapse');
|
|
26
|
+
|
|
27
|
+
var _Collapse2 = _interopRequireDefault(_Collapse);
|
|
20
28
|
|
|
21
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
30
|
|
|
@@ -39,6 +47,7 @@ var SelectOption = function (_Component) {
|
|
|
39
47
|
|
|
40
48
|
_this.onClick = _this.onClick.bind(_this);
|
|
41
49
|
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
|
|
50
|
+
_this.onCollapseClick = _this.onCollapseClick.bind(_this);
|
|
42
51
|
return _this;
|
|
43
52
|
}
|
|
44
53
|
|
|
@@ -47,7 +56,7 @@ var SelectOption = function (_Component) {
|
|
|
47
56
|
value: function shouldComponentUpdate(nextProps) {
|
|
48
57
|
// check only interesting props
|
|
49
58
|
var currentProps = this.props;
|
|
50
|
-
var propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted'];
|
|
59
|
+
var propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted', 'collapsibleState', 'currentText'];
|
|
51
60
|
|
|
52
61
|
return propsToCheck.map(function (val) {
|
|
53
62
|
return (0, _isEqual2.default)(currentProps[val], nextProps[val]);
|
|
@@ -84,22 +93,43 @@ var SelectOption = function (_Component) {
|
|
|
84
93
|
setIndex(index);
|
|
85
94
|
}
|
|
86
95
|
}
|
|
96
|
+
}, {
|
|
97
|
+
key: 'onCollapseClick',
|
|
98
|
+
value: function onCollapseClick(e) {
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
101
|
+
var _props3 = this.props,
|
|
102
|
+
toggleCollapsedValue = _props3.toggleCollapsedValue,
|
|
103
|
+
option = _props3.option;
|
|
104
|
+
|
|
105
|
+
toggleCollapsedValue(option.value);
|
|
106
|
+
}
|
|
87
107
|
}, {
|
|
88
108
|
key: 'render',
|
|
89
109
|
value: function render() {
|
|
110
|
+
var _props4 = this.props,
|
|
111
|
+
isSelected = _props4.isSelected,
|
|
112
|
+
option = _props4.option,
|
|
113
|
+
id = _props4.id,
|
|
114
|
+
className = _props4.className,
|
|
115
|
+
collapsibleState = _props4.collapsibleState,
|
|
116
|
+
renderOptionLabel = _props4.renderOptionLabel;
|
|
117
|
+
|
|
118
|
+
|
|
90
119
|
return _react2.default.createElement(
|
|
91
120
|
'li',
|
|
92
121
|
{
|
|
93
|
-
'aria-selected':
|
|
94
|
-
'aria-disabled':
|
|
95
|
-
'aria-label':
|
|
96
|
-
className:
|
|
97
|
-
id:
|
|
122
|
+
'aria-selected': isSelected,
|
|
123
|
+
'aria-disabled': option.disabled,
|
|
124
|
+
'aria-label': renderOptionLabel(this.props.option),
|
|
125
|
+
className: (0, _classnames2.default)(className, option.optionClassName),
|
|
126
|
+
id: id,
|
|
98
127
|
onClick: this.onClick,
|
|
99
128
|
onMouseEnter: this.onMouseEnter,
|
|
100
129
|
role: 'option',
|
|
101
130
|
tabIndex: '-1'
|
|
102
131
|
},
|
|
132
|
+
collapsibleState && _react2.default.createElement(_Collapse2.default, { collapsibleState: collapsibleState, onClick: this.onCollapseClick }),
|
|
103
133
|
this.props.children
|
|
104
134
|
);
|
|
105
135
|
}
|
|
@@ -122,5 +152,8 @@ SelectOption.propTypes = {
|
|
|
122
152
|
setIndex: _propTypes2.default.func.isRequired,
|
|
123
153
|
toggleValue: _propTypes2.default.func.isRequired,
|
|
124
154
|
unselectOnClick: _propTypes2.default.bool,
|
|
125
|
-
id: _propTypes2.default.string
|
|
155
|
+
id: _propTypes2.default.string,
|
|
156
|
+
toggleCollapsedValue: _propTypes2.default.func.isRequired,
|
|
157
|
+
collapsibleState: _propTypes2.default.string,
|
|
158
|
+
currentText: _propTypes2.default.string
|
|
126
159
|
};
|
|
@@ -70,6 +70,7 @@ function SingleSelect(props) {
|
|
|
70
70
|
onClose: props.onClose,
|
|
71
71
|
options: props.options,
|
|
72
72
|
optionSets: props.optionSets,
|
|
73
|
+
onChangeText: props.onChangeText,
|
|
73
74
|
placeholder: props.placeholder,
|
|
74
75
|
renderValueLabel: props.renderValueLabel,
|
|
75
76
|
renderOptionLabel: props.renderOptionLabel,
|
|
@@ -92,6 +93,7 @@ SingleSelect.propTypes = {
|
|
|
92
93
|
onChange: _propTypes2.default.func,
|
|
93
94
|
onClose: _propTypes2.default.func,
|
|
94
95
|
onOpen: _propTypes2.default.func,
|
|
96
|
+
onChangeText: _propTypes2.default.func,
|
|
95
97
|
OptionComponent: _propTypes2.default.func,
|
|
96
98
|
renderOptionLabel: _propTypes2.default.func,
|
|
97
99
|
renderValueLabel: _propTypes2.default.func,
|
|
@@ -49,6 +49,7 @@ function TagBoxMenuSelect(props) {
|
|
|
49
49
|
closeOnSelect: false,
|
|
50
50
|
|
|
51
51
|
ariaLabel: props.ariaLabel,
|
|
52
|
+
collapsibleOptions: props.collapsibleOptions,
|
|
52
53
|
filterable: props.filterable,
|
|
53
54
|
disabled: props.disabled,
|
|
54
55
|
onChange: props.onChange,
|
|
@@ -65,6 +66,7 @@ function TagBoxMenuSelect(props) {
|
|
|
65
66
|
|
|
66
67
|
TagBoxMenuSelect.propTypes = {
|
|
67
68
|
ariaLabel: _propTypes2.default.string,
|
|
69
|
+
collapsibleOptions: _propTypes2.default.array,
|
|
68
70
|
filterable: _propTypes2.default.bool,
|
|
69
71
|
disabled: _propTypes2.default.bool,
|
|
70
72
|
options: _propTypes2.default.array.isRequired,
|
|
@@ -18,7 +18,19 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
|
|
21
22
|
.highlighted {
|
|
22
23
|
background-color: $select-hover-background-color;
|
|
23
24
|
color: $select-hover-text-color;
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
.collapse {
|
|
28
|
+
vertical-align: top;
|
|
29
|
+
padding-right: 8px;
|
|
30
|
+
width: 16px;
|
|
31
|
+
display: inline-block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.option .collapse-icon {
|
|
35
|
+
font-size: 10px;
|
|
36
|
+
}
|
|
@@ -1,57 +1 @@
|
|
|
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
|
-
}
|
|
1
|
+
@font-face{font-family:Pam;src:url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAATQAA0AAAAABsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAEtAAAABoAAAAcks96/k9TLzIAAAGgAAAARQAAAGAQ+ZEfY21hcAAAAggAAABRAAABWuAdGx9jdnQgAAACXAAAAAQAAAAEACECf2dhc3AAAASsAAAACAAAAAj//wADZ2x5ZgAAAngAAADxAAABNEdgU4hoZWFkAAABMAAAADAAAAA2HSPkrWhoZWEAAAFgAAAAHgAAACQHrQSMaG10eAAAAegAAAAeAAAAMCG7ACFsb2NhAAACYAAAABgAAAAaAfQBvG1heHAAAAGAAAAAHwAAACAAUAA7bmFtZQAAA2wAAAD1AAABlVlRUkBwb3N0AAAEZAAAAEgAAAByU/Amd3jaY2BkYGAAYsH2usp4fpuvDNzMH4AiDHe5AioQ9P8C5g/MCUAuBwMTSBQAI7oKXHjaY2BkYGBOYJjAEM38gYHh/38gCRRBATwAeuwFQQAAeNpjYGRgYOBh4GJgYgABEMnIABJzYNADCQAABYsAjAB42mNgYS5knMDAysDA1M90kIGBoRdCMz5mMGJkAYoysDIzwACjAAMaaGBg+MDKnPC/gCGaOYFhApDLiCSrwMAIADXCCrEAAAB42mPMYVBkAALGAAYG5g+YmOkzgmasZGAAAMeCCPYAAHjaY2BgYGaAYBkGRgYQCAHyGMF8FgYLIM3FwMHABIQMDLwMCh9Y//8HqwKxGYBs5v/f/z8VYIPqhQJGNoiRYDZIJwsDKgCqZmUY3gAAnJMLMAAAAAAhAn942mNgYNBCgm4MMQxZDA0MfQyzAB+6A7F42m2OsUrDYBSFz7nXNEQc8gvFjv2REnBQsLhlcMxTlAwdM3TOA3Ry6CMEJ9fkCcSlL+EgDkUEpUPGJPX/oYKDw4XLOfc750JgAV5JBUWI65q4SZvwBF+39Sh4TRsVt6JWLwdebsIRu7Sh1+fGmmRuLi2jj+1Wqj63sgAEOKx0rzkCRMCMCZOQ7pYvfCiGt8dC0y7OjrucdrHugb+c/wUX1tiZozLNu0qfHKF59ntLN4W03HnKWEo7rLkb1v/k8M6OfbtO+meddDGnm43cH4N8zqe0svRURMuSZX8mS5/kvMM3S3n33tiQ5bmv+QHc5E1JAAAAeNpVjjFqw0AQRZ8s2SEQUocUYbtUcqQN2GDSmICbNMaFexVCGGwJVjI+Q26SKqTIOXKBlLlIvqxpvMvsvpnZ+X+BWz6JGNYN98YRMU/GI654NY554N04UfZlPNbsj/FE9T9FlFwruztP9Ryp82g8ku+zccwLb8aJ3nwYjzX7bTzR/mVFQ6DDseRESav8oJtVEzq3PJVtc1C2plCZdaFjo3bFkb1qQWlZHfeFoJeqJTVIVnrl8EzJdC8Ug8bAM1LmCq+uJ+/t6k6WVen8NHMLJyeds3Se+sznlx/YSjrop7uzodP4YMK2DO2uqV0uiYuRf+FJNRMAAAB42mNgYgCD/00MRgzYAA8QMzIwMTIxMjMwM7IwsjKyMbIzcjBysviF+vgwOQexl+ZluhkYGEBpQyhtBKWNobQJlDYFAGghENcAAAAB//8AAnjaY2BgYGQAghu7bvGC6LtcARUwGgBF4AXZAAA=) format('woff');font-weight:400;font-style:normal}.pamicon{display:inline-block;font:normal normal normal 14px/1 Pam;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pamicon-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.pamicon-2x{font-size:2em}.pamicon-3x{font-size:3em}.pamicon-4x{font-size:4em}.pamicon-5x{font-size:5em}.pamicon-checkbox-checked:before{content:'\f000'}.pamicon-checkbox-unchecked:before{content:'\f001'}.pamicon-triangle-down:before{content:'\f002'}.pamicon-checkbox-intermediate:before{content:'\f003'}.pamicon-triangle-up:before{content:'\f004'}.pamicon-triangle-right:before{content:'\f005'}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}
|