@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
package/.idea/misc.xml
ADDED
package/.idea/pam.iml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
<component name="TemplatesService">
|
|
9
|
+
<option name="TEMPLATE_FOLDERS">
|
|
10
|
+
<list>
|
|
11
|
+
<option value="$MODULE_DIR$/node_modules/istanbul-reports/lib/html/templates" />
|
|
12
|
+
</list>
|
|
13
|
+
</option>
|
|
14
|
+
</component>
|
|
15
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/README.md
CHANGED
|
@@ -47,3 +47,29 @@ Pam loads css via sass-loader and css-loader with cssModules. To use in webpack,
|
|
|
47
47
|
include: [/node_modules\/@nestio\/pam\//],
|
|
48
48
|
},
|
|
49
49
|
```
|
|
50
|
+
|
|
51
|
+
### Legal Stuff
|
|
52
|
+
|
|
53
|
+
~~~
|
|
54
|
+
MIT License
|
|
55
|
+
|
|
56
|
+
Copyright (c) 2022 Funnel Leasing, Inc.
|
|
57
|
+
|
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
59
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
60
|
+
in the Software without restriction, including without limitation the rights
|
|
61
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
62
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
63
|
+
furnished to do so, subject to the following conditions:
|
|
64
|
+
|
|
65
|
+
The above copyright notice and this permission notice shall be included in all
|
|
66
|
+
copies or substantial portions of the Software.
|
|
67
|
+
|
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
69
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
70
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
71
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
72
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
73
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
74
|
+
SOFTWARE.
|
|
75
|
+
~~~
|
|
@@ -32,20 +32,6 @@ 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
|
-
|
|
49
35
|
const Circle = (props) => (
|
|
50
36
|
<div style={{
|
|
51
37
|
display: 'inline-block',
|
|
@@ -128,12 +114,23 @@ export default function SelectPage () {
|
|
|
128
114
|
</div>
|
|
129
115
|
</label>
|
|
130
116
|
</ExamplePanel>
|
|
117
|
+
<ExamplePanel title="MultiSelect with multiple sets">
|
|
118
|
+
<label>
|
|
119
|
+
<span>Label for multiple sets</span>
|
|
120
|
+
<div>
|
|
121
|
+
<MultiSelect
|
|
122
|
+
options={multipleSetOptions}
|
|
123
|
+
optionSets={['Set 1', 'Set 2']}
|
|
124
|
+
value={[0]}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
</label>
|
|
128
|
+
</ExamplePanel>
|
|
131
129
|
<ExamplePanel title="Filterable Select">
|
|
132
130
|
<SingleSelect
|
|
133
131
|
options={basicOptions}
|
|
134
132
|
value="1"
|
|
135
133
|
filterable={true}
|
|
136
|
-
onChangeText={(t) => console.log(t)}
|
|
137
134
|
/>
|
|
138
135
|
</ExamplePanel>
|
|
139
136
|
<ExamplePanel title="Custom Option Select">
|
|
@@ -213,17 +210,6 @@ export default function SelectPage () {
|
|
|
213
210
|
<ExamplePanel title="Programmatic Manipulation">
|
|
214
211
|
<Container />
|
|
215
212
|
</ExamplePanel>
|
|
216
|
-
<ExamplePanel title="Custom Option Classname">
|
|
217
|
-
<MultiSelect
|
|
218
|
-
options={customClassNameOptions}
|
|
219
|
-
/>
|
|
220
|
-
</ExamplePanel>
|
|
221
|
-
<ExamplePanel title="Collapsible Multiselect">
|
|
222
|
-
<TagBoxMenuSelect
|
|
223
|
-
options={collapsibleOptions}
|
|
224
|
-
collapsibleOptions={[1, 3]}
|
|
225
|
-
/>
|
|
226
|
-
</ExamplePanel>
|
|
227
213
|
</Page>
|
|
228
214
|
);
|
|
229
215
|
}
|
package/examples/index.html
CHANGED
|
@@ -57,18 +57,17 @@ function MultiSelect(props) {
|
|
|
57
57
|
onClose: props.onClose,
|
|
58
58
|
onOpen: props.onOpen,
|
|
59
59
|
options: props.options,
|
|
60
|
+
optionSets: props.optionSets,
|
|
60
61
|
renderOptionLabel: props.renderOptionLabel,
|
|
61
62
|
renderValueLabel: props.renderValueLabel,
|
|
62
63
|
value: props.value,
|
|
63
64
|
valueAdapter: valueAdapter,
|
|
64
|
-
ValueComponent: props.ValueComponent
|
|
65
|
-
collapsibleOptions: props.collapsibleOptions
|
|
65
|
+
ValueComponent: props.ValueComponent
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
MultiSelect.propTypes = {
|
|
70
70
|
ariaLabel: _propTypes2.default.string,
|
|
71
|
-
collapsibleOptions: _propTypes2.default.array,
|
|
72
71
|
filterable: _propTypes2.default.bool,
|
|
73
72
|
menuContainerClassName: _propTypes2.default.string,
|
|
74
73
|
menuContainerText: _propTypes2.default.string,
|
|
@@ -78,6 +77,7 @@ MultiSelect.propTypes = {
|
|
|
78
77
|
onClose: _propTypes2.default.func,
|
|
79
78
|
onOpen: _propTypes2.default.func,
|
|
80
79
|
options: _propTypes2.default.array.isRequired,
|
|
80
|
+
optionSets: _propTypes2.default.array,
|
|
81
81
|
renderOptionLabel: _propTypes2.default.func,
|
|
82
82
|
renderValueLabel: _propTypes2.default.func,
|
|
83
83
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
@@ -38,26 +38,9 @@ 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
|
|
42
|
-
currentText = props.currentText,
|
|
43
|
-
collapsibleOptions = props.collapsibleOptions;
|
|
41
|
+
option = props.option;
|
|
44
42
|
|
|
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());
|
|
43
|
+
var optionClass = (0, _classnames4.default)(_MultiSelectOption2.default.option, option.disabled && _MultiSelectOption2.default.disabled, isHighlighted && _MultiSelectOption2.default.highlighted);
|
|
61
44
|
|
|
62
45
|
var checkboxClass = (0, _classnames4.default)(_defineProperty({}, _MultiSelectOption2.default.checked, isSelected), _defineProperty({}, _MultiSelectOption2.default.unchecked, !isSelected));
|
|
63
46
|
var label = props.renderOptionLabel(props.option);
|
|
@@ -83,9 +66,7 @@ MultiSelectOption.propTypes = {
|
|
|
83
66
|
isHighlighted: _propTypes2.default.bool.isRequired,
|
|
84
67
|
isSelected: _propTypes2.default.bool.isRequired,
|
|
85
68
|
option: _propTypes2.default.object.isRequired,
|
|
86
|
-
renderOptionLabel: _propTypes2.default.func
|
|
87
|
-
collapsibleOptions: _propTypes2.default.array,
|
|
88
|
-
currentText: _propTypes2.default.string
|
|
69
|
+
renderOptionLabel: _propTypes2.default.func
|
|
89
70
|
};
|
|
90
71
|
|
|
91
72
|
MultiSelectOption.defaultProps = {
|
|
@@ -150,15 +150,14 @@ 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
|
+
|
|
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
|
-
|
|
162
161
|
var rendered = _react2.default.createElement(OptionComponent, _extends({
|
|
163
162
|
id: _this3.getOptionId(option, index),
|
|
164
163
|
key: option.value,
|
|
@@ -166,8 +165,7 @@ var OptionListSet = function (_Component) {
|
|
|
166
165
|
index: index,
|
|
167
166
|
isSelected: valueIsSelected(option),
|
|
168
167
|
renderOptionLabel: renderOptionLabel,
|
|
169
|
-
isHighlighted: index === optionIndex
|
|
170
|
-
collapsibleState: getCollapsibleState(option.value)
|
|
168
|
+
isHighlighted: index === optionIndex
|
|
171
169
|
}, _this3.props));
|
|
172
170
|
return rendered;
|
|
173
171
|
});
|
|
@@ -285,7 +283,6 @@ OptionListSet.propTypes = {
|
|
|
285
283
|
OptionComponent
|
|
286
284
|
*/
|
|
287
285
|
renderOptionLabel: _propTypes2.default.func,
|
|
288
|
-
|
|
289
286
|
/**
|
|
290
287
|
Currently highlighted option
|
|
291
288
|
*/
|
|
@@ -294,11 +291,6 @@ OptionListSet.propTypes = {
|
|
|
294
291
|
OptionComponent to be rendered in OptionList
|
|
295
292
|
*/
|
|
296
293
|
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,
|
|
302
294
|
/**
|
|
303
295
|
Function used to determine if individual options are selected
|
|
304
296
|
*/
|
|
@@ -45,12 +45,8 @@ var _SelectCore = require('./styles/SelectCore.scss');
|
|
|
45
45
|
|
|
46
46
|
var _SelectCore2 = _interopRequireDefault(_SelectCore);
|
|
47
47
|
|
|
48
|
-
var _constants = require('../constants');
|
|
49
|
-
|
|
50
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
49
|
|
|
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
|
-
|
|
54
50
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
55
51
|
|
|
56
52
|
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; }
|
|
@@ -79,7 +75,6 @@ var SelectCore = function (_Component) {
|
|
|
79
75
|
_this.changeValue = _this.changeValue.bind(_this);
|
|
80
76
|
_this.clearValue = _this.clearValue.bind(_this);
|
|
81
77
|
_this.closeMenu = _this.closeMenu.bind(_this);
|
|
82
|
-
_this.getCollapsibleState = _this.getCollapsibleState.bind(_this);
|
|
83
78
|
_this.onBackspace = _this.onBackspace.bind(_this);
|
|
84
79
|
_this.onDown = _this.onDown.bind(_this);
|
|
85
80
|
_this.onEnter = _this.onEnter.bind(_this);
|
|
@@ -89,7 +84,6 @@ var SelectCore = function (_Component) {
|
|
|
89
84
|
_this.onEscape = _this.onEscape.bind(_this);
|
|
90
85
|
_this.openMenu = _this.openMenu.bind(_this);
|
|
91
86
|
_this.setIndex = _this.setIndex.bind(_this);
|
|
92
|
-
_this.toggleCollapsedValue = _this.toggleCollapsedValue.bind(_this);
|
|
93
87
|
_this.toggleValue = _this.toggleValue.bind(_this);
|
|
94
88
|
_this.valueIsSelected = _this.valueIsSelected.bind(_this);
|
|
95
89
|
|
|
@@ -101,8 +95,7 @@ var SelectCore = function (_Component) {
|
|
|
101
95
|
isOpen: false,
|
|
102
96
|
optionIndex: _this._getInitialOptionIndex(props),
|
|
103
97
|
options: props.options || null,
|
|
104
|
-
loading: false
|
|
105
|
-
collapsedOptions: {}
|
|
98
|
+
loading: false
|
|
106
99
|
};
|
|
107
100
|
|
|
108
101
|
_this.menuRef = _react2.default.createRef();
|
|
@@ -173,19 +166,11 @@ var SelectCore = function (_Component) {
|
|
|
173
166
|
}, {
|
|
174
167
|
key: 'componentDidUpdate',
|
|
175
168
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
176
|
-
var
|
|
177
|
-
onOptionsFiltered = _props2.onOptionsFiltered,
|
|
178
|
-
onChangeText = _props2.onChangeText;
|
|
169
|
+
var onOptionsFiltered = this.props.onOptionsFiltered;
|
|
179
170
|
|
|
180
171
|
|
|
181
|
-
if (prevState.currentText !== this.state.currentText) {
|
|
182
|
-
|
|
183
|
-
onOptionsFiltered(this._getFilteredOptions());
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (onChangeText) {
|
|
187
|
-
onChangeText(this.state.currentText);
|
|
188
|
-
}
|
|
172
|
+
if (onOptionsFiltered && prevState.currentText !== this.state.currentText) {
|
|
173
|
+
onOptionsFiltered(this._getFilteredOptions());
|
|
189
174
|
}
|
|
190
175
|
}
|
|
191
176
|
|
|
@@ -211,10 +196,10 @@ var SelectCore = function (_Component) {
|
|
|
211
196
|
}, {
|
|
212
197
|
key: 'closeMenu',
|
|
213
198
|
value: function closeMenu() {
|
|
214
|
-
var
|
|
215
|
-
alwaysOpen =
|
|
216
|
-
disableOnClickOutside =
|
|
217
|
-
onClose =
|
|
199
|
+
var _props2 = this.props,
|
|
200
|
+
alwaysOpen = _props2.alwaysOpen,
|
|
201
|
+
disableOnClickOutside = _props2.disableOnClickOutside,
|
|
202
|
+
onClose = _props2.onClose;
|
|
218
203
|
|
|
219
204
|
|
|
220
205
|
if (alwaysOpen) return;
|
|
@@ -238,11 +223,11 @@ var SelectCore = function (_Component) {
|
|
|
238
223
|
value: function openMenu() {
|
|
239
224
|
var _this2 = this;
|
|
240
225
|
|
|
241
|
-
var
|
|
242
|
-
alwaysOpen =
|
|
243
|
-
enableOnClickOutside =
|
|
244
|
-
onOpen =
|
|
245
|
-
disabled =
|
|
226
|
+
var _props3 = this.props,
|
|
227
|
+
alwaysOpen = _props3.alwaysOpen,
|
|
228
|
+
enableOnClickOutside = _props3.enableOnClickOutside,
|
|
229
|
+
onOpen = _props3.onOpen,
|
|
230
|
+
disabled = _props3.disabled;
|
|
246
231
|
|
|
247
232
|
|
|
248
233
|
if (disabled) return;
|
|
@@ -495,18 +480,6 @@ var SelectCore = function (_Component) {
|
|
|
495
480
|
}
|
|
496
481
|
});
|
|
497
482
|
}
|
|
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
|
-
}
|
|
510
483
|
|
|
511
484
|
// Async functions
|
|
512
485
|
/**
|
|
@@ -569,29 +542,6 @@ var SelectCore = function (_Component) {
|
|
|
569
542
|
value: function valueIsSelected(newValue) {
|
|
570
543
|
return this.props.valueAdapter.valueIsSelected(this.state.currentValue, newValue);
|
|
571
544
|
}
|
|
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
|
-
}
|
|
595
545
|
|
|
596
546
|
// Private methods and helpers
|
|
597
547
|
/**
|
|
@@ -613,21 +563,13 @@ var SelectCore = function (_Component) {
|
|
|
613
563
|
return this.state.options;
|
|
614
564
|
}
|
|
615
565
|
|
|
616
|
-
var args = [this.state.options, this.props.filterOption, text
|
|
617
|
-
if (this._cachedArgs && this._cachedArgs.
|
|
618
|
-
return args[i] === arg;
|
|
619
|
-
})) {
|
|
566
|
+
var args = [this.state.options, this.props.filterOption, text];
|
|
567
|
+
if (this._cachedArgs && this._cachedArgs[0] == args[0] && this._cachedArgs[1] == args[1] && this._cachedArgs[2] == args[2]) {
|
|
620
568
|
return this._cachedResult;
|
|
621
569
|
}
|
|
622
570
|
|
|
623
571
|
this._cachedArgs = args;
|
|
624
572
|
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
|
-
}
|
|
631
573
|
return _this7.props.filterOption(option, text);
|
|
632
574
|
});
|
|
633
575
|
|
|
@@ -761,17 +703,16 @@ var SelectCore = function (_Component) {
|
|
|
761
703
|
optionIndex: this.state.optionIndex,
|
|
762
704
|
setIndex: this.setIndex,
|
|
763
705
|
shouldShowOptionList: this._shouldShowOptionList(),
|
|
764
|
-
toggleValue: this.toggleValue
|
|
765
|
-
toggleCollapsedValue: this.toggleCollapsedValue
|
|
706
|
+
toggleValue: this.toggleValue
|
|
766
707
|
});
|
|
767
708
|
}
|
|
768
709
|
}, {
|
|
769
710
|
key: 'renderMenu',
|
|
770
711
|
value: function renderMenu() {
|
|
771
|
-
var
|
|
772
|
-
MenuComponent =
|
|
773
|
-
OptionComponent =
|
|
774
|
-
renderOptionLabel =
|
|
712
|
+
var _props4 = this.props,
|
|
713
|
+
MenuComponent = _props4.MenuComponent,
|
|
714
|
+
OptionComponent = _props4.OptionComponent,
|
|
715
|
+
renderOptionLabel = _props4.renderOptionLabel;
|
|
775
716
|
|
|
776
717
|
var options = this._getFilteredOptions();
|
|
777
718
|
var props = this.generateChildProps();
|
|
@@ -779,7 +720,6 @@ var SelectCore = function (_Component) {
|
|
|
779
720
|
return _react2.default.createElement(MenuComponent, _extends({
|
|
780
721
|
options: options,
|
|
781
722
|
valueIsSelected: this.valueIsSelected,
|
|
782
|
-
getCollapsibleState: this.getCollapsibleState,
|
|
783
723
|
OptionComponent: OptionComponent,
|
|
784
724
|
renderOptionLabel: renderOptionLabel,
|
|
785
725
|
onUp: this.onUp,
|
|
@@ -855,6 +795,11 @@ SelectCore.propTypes = {
|
|
|
855
795
|
*/
|
|
856
796
|
filterOption: _propTypes2.default.func,
|
|
857
797
|
/**
|
|
798
|
+
Function intercepts input value change
|
|
799
|
+
* @param {string} str
|
|
800
|
+
*/
|
|
801
|
+
handleValueChange: _propTypes2.default.func,
|
|
802
|
+
/**
|
|
858
803
|
Function used to fetch async options. Is invoked with currentText and should return a promise with the options
|
|
859
804
|
* @param {string} str
|
|
860
805
|
* @returns {Promise}
|
|
@@ -956,10 +901,7 @@ SelectCore.propTypes = {
|
|
|
956
901
|
disableOnClickOutside: _propTypes2.default.func,
|
|
957
902
|
disabled: _propTypes2.default.bool,
|
|
958
903
|
filterable: _propTypes2.default.bool,
|
|
959
|
-
onOptionsFiltered: _propTypes2.default.func
|
|
960
|
-
onChangeText: _propTypes2.default.func,
|
|
961
|
-
collapsibleOptions: _propTypes2.default.array
|
|
962
|
-
|
|
904
|
+
onOptionsFiltered: _propTypes2.default.func
|
|
963
905
|
};
|
|
964
906
|
|
|
965
907
|
SelectCore.defaultProps = {
|
|
@@ -6,25 +6,17 @@ 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
|
|
10
|
-
|
|
11
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
12
|
-
|
|
13
|
-
var _isEqual = require('lodash/isEqual');
|
|
9
|
+
var _react = require('react');
|
|
14
10
|
|
|
15
|
-
var
|
|
11
|
+
var _react2 = _interopRequireDefault(_react);
|
|
16
12
|
|
|
17
13
|
var _propTypes = require('prop-types');
|
|
18
14
|
|
|
19
15
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
20
16
|
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
var _react2 = _interopRequireDefault(_react);
|
|
24
|
-
|
|
25
|
-
var _Collapse = require('./Collapse');
|
|
17
|
+
var _isEqual = require('lodash/isEqual');
|
|
26
18
|
|
|
27
|
-
var
|
|
19
|
+
var _isEqual2 = _interopRequireDefault(_isEqual);
|
|
28
20
|
|
|
29
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
22
|
|
|
@@ -47,7 +39,6 @@ var SelectOption = function (_Component) {
|
|
|
47
39
|
|
|
48
40
|
_this.onClick = _this.onClick.bind(_this);
|
|
49
41
|
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
|
|
50
|
-
_this.onCollapseClick = _this.onCollapseClick.bind(_this);
|
|
51
42
|
return _this;
|
|
52
43
|
}
|
|
53
44
|
|
|
@@ -56,7 +47,7 @@ var SelectOption = function (_Component) {
|
|
|
56
47
|
value: function shouldComponentUpdate(nextProps) {
|
|
57
48
|
// check only interesting props
|
|
58
49
|
var currentProps = this.props;
|
|
59
|
-
var propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted'
|
|
50
|
+
var propsToCheck = ['isSelected', 'option', 'disabled', 'isHighlighted'];
|
|
60
51
|
|
|
61
52
|
return propsToCheck.map(function (val) {
|
|
62
53
|
return (0, _isEqual2.default)(currentProps[val], nextProps[val]);
|
|
@@ -93,43 +84,22 @@ var SelectOption = function (_Component) {
|
|
|
93
84
|
setIndex(index);
|
|
94
85
|
}
|
|
95
86
|
}
|
|
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
|
-
}
|
|
107
87
|
}, {
|
|
108
88
|
key: 'render',
|
|
109
89
|
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
|
-
|
|
119
90
|
return _react2.default.createElement(
|
|
120
91
|
'li',
|
|
121
92
|
{
|
|
122
|
-
'aria-selected': isSelected,
|
|
123
|
-
'aria-disabled': option.disabled,
|
|
124
|
-
'aria-label': renderOptionLabel(this.props.option),
|
|
125
|
-
className:
|
|
126
|
-
id: id,
|
|
93
|
+
'aria-selected': this.props.isSelected,
|
|
94
|
+
'aria-disabled': this.props.option.disabled,
|
|
95
|
+
'aria-label': this.props.renderOptionLabel(this.props.option),
|
|
96
|
+
className: this.props.className,
|
|
97
|
+
id: this.props.id,
|
|
127
98
|
onClick: this.onClick,
|
|
128
99
|
onMouseEnter: this.onMouseEnter,
|
|
129
100
|
role: 'option',
|
|
130
101
|
tabIndex: '-1'
|
|
131
102
|
},
|
|
132
|
-
collapsibleState && _react2.default.createElement(_Collapse2.default, { collapsibleState: collapsibleState, onClick: this.onCollapseClick }),
|
|
133
103
|
this.props.children
|
|
134
104
|
);
|
|
135
105
|
}
|
|
@@ -152,8 +122,5 @@ SelectOption.propTypes = {
|
|
|
152
122
|
setIndex: _propTypes2.default.func.isRequired,
|
|
153
123
|
toggleValue: _propTypes2.default.func.isRequired,
|
|
154
124
|
unselectOnClick: _propTypes2.default.bool,
|
|
155
|
-
id: _propTypes2.default.string
|
|
156
|
-
toggleCollapsedValue: _propTypes2.default.func.isRequired,
|
|
157
|
-
collapsibleState: _propTypes2.default.string,
|
|
158
|
-
currentText: _propTypes2.default.string
|
|
125
|
+
id: _propTypes2.default.string
|
|
159
126
|
};
|
|
@@ -70,7 +70,6 @@ function SingleSelect(props) {
|
|
|
70
70
|
onClose: props.onClose,
|
|
71
71
|
options: props.options,
|
|
72
72
|
optionSets: props.optionSets,
|
|
73
|
-
onChangeText: props.onChangeText,
|
|
74
73
|
placeholder: props.placeholder,
|
|
75
74
|
renderValueLabel: props.renderValueLabel,
|
|
76
75
|
renderOptionLabel: props.renderOptionLabel,
|
|
@@ -93,7 +92,6 @@ SingleSelect.propTypes = {
|
|
|
93
92
|
onChange: _propTypes2.default.func,
|
|
94
93
|
onClose: _propTypes2.default.func,
|
|
95
94
|
onOpen: _propTypes2.default.func,
|
|
96
|
-
onChangeText: _propTypes2.default.func,
|
|
97
95
|
OptionComponent: _propTypes2.default.func,
|
|
98
96
|
renderOptionLabel: _propTypes2.default.func,
|
|
99
97
|
renderValueLabel: _propTypes2.default.func,
|
|
@@ -49,7 +49,6 @@ function TagBoxMenuSelect(props) {
|
|
|
49
49
|
closeOnSelect: false,
|
|
50
50
|
|
|
51
51
|
ariaLabel: props.ariaLabel,
|
|
52
|
-
collapsibleOptions: props.collapsibleOptions,
|
|
53
52
|
filterable: props.filterable,
|
|
54
53
|
disabled: props.disabled,
|
|
55
54
|
onChange: props.onChange,
|
|
@@ -66,7 +65,6 @@ function TagBoxMenuSelect(props) {
|
|
|
66
65
|
|
|
67
66
|
TagBoxMenuSelect.propTypes = {
|
|
68
67
|
ariaLabel: _propTypes2.default.string,
|
|
69
|
-
collapsibleOptions: _propTypes2.default.array,
|
|
70
68
|
filterable: _propTypes2.default.bool,
|
|
71
69
|
disabled: _propTypes2.default.bool,
|
|
72
70
|
options: _propTypes2.default.array.isRequired,
|
|
@@ -18,19 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
.highlighted {
|
|
23
22
|
background-color: $select-hover-background-color;
|
|
24
23
|
color: $select-hover-text-color;
|
|
25
24
|
}
|
|
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
|
-
}
|