@nestio/pam 2.0.7 → 2.0.9-beta.0
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/.buildkite/docker-compose-ci.yml +1 -1
- package/.buildkite/test.sh +1 -1
- package/.nvmrc +1 -0
- package/README.md +1 -1
- package/examples/components/Async.jsx +6 -0
- package/examples/components/CalendarSelect.jsx +5 -0
- package/examples/components/Select.jsx +29 -2
- package/examples/components/TabbedSelect.jsx +1 -0
- package/lib/components/AsyncSelect.js +4 -2
- package/lib/components/BadgeMultiSelect.js +4 -2
- package/lib/components/CalendarInput.js +5 -2
- package/lib/components/CalendarRangeSelect.js +2 -1
- package/lib/components/CalendarSelect.js +5 -2
- package/lib/components/MultiSelect.js +4 -2
- package/lib/components/OptionListSet.js +7 -0
- package/lib/components/SelectCore.js +5 -2
- package/lib/components/SingleSelect.js +4 -2
- package/lib/components/TabbedSelect.js +4 -2
- package/lib/components/TagBoxMenuSelect.js +4 -2
- package/lib/components/TagBoxValueSelect.js +4 -2
- package/package.json +7 -7
- package/src/components/AsyncSelect.jsx +3 -1
- package/src/components/BadgeMultiSelect.jsx +3 -1
- package/src/components/CalendarInput.jsx +3 -1
- package/src/components/CalendarRangeSelect.jsx +2 -1
- package/src/components/CalendarSelect.jsx +3 -1
- package/src/components/MultiSelect.jsx +3 -1
- package/src/components/OptionListSet.jsx +6 -0
- package/src/components/SelectCore.jsx +5 -2
- package/src/components/SingleSelect.jsx +3 -1
- package/src/components/TabbedSelect.jsx +3 -1
- package/src/components/TagBoxMenuSelect.jsx +3 -1
- package/src/components/TagBoxValueSelect.jsx +2 -0
- package/src/components/__tests__/OptionListSet.spec.js +16 -3
package/.buildkite/test.sh
CHANGED
|
@@ -7,7 +7,7 @@ set -eo pipefail
|
|
|
7
7
|
DOCKER_RUN_APP_CMD="docker-compose -f ./.buildkite/docker-compose-ci.yml run --rm pam"
|
|
8
8
|
|
|
9
9
|
echo -e "--- Setting Up Environment"
|
|
10
|
-
$DOCKER_RUN_APP_CMD /bin/bash -c "rm -rf node_modules && rm -rf lib && npm
|
|
10
|
+
$DOCKER_RUN_APP_CMD /bin/bash -c "rm -rf node_modules && rm -rf lib && npm ci"
|
|
11
11
|
|
|
12
12
|
echo -e "--- Running JS Tests"
|
|
13
13
|
$DOCKER_RUN_APP_CMD npm run test
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
12
|
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ export default function AsyncPage () {
|
|
|
77
77
|
loadOptions={APISpoofer}
|
|
78
78
|
processLoadOptions={processLoadOptions}
|
|
79
79
|
minLength={2}
|
|
80
|
+
id="async-single-select"
|
|
80
81
|
/>
|
|
81
82
|
</ExamplePanel>
|
|
82
83
|
<ExamplePanel title="Disabled Async Single Select">
|
|
@@ -85,6 +86,7 @@ export default function AsyncPage () {
|
|
|
85
86
|
processLoadOptions={processLoadOptions}
|
|
86
87
|
minLength={2}
|
|
87
88
|
disabled
|
|
89
|
+
id="disabled-async-single-select"
|
|
88
90
|
/>
|
|
89
91
|
</ExamplePanel>
|
|
90
92
|
<ExamplePanel title="Async Multi Select">
|
|
@@ -92,6 +94,7 @@ export default function AsyncPage () {
|
|
|
92
94
|
loadOptions={APISpoofer}
|
|
93
95
|
processLoadOptions={processLoadOptions}
|
|
94
96
|
multiple={true}
|
|
97
|
+
id="async-multi-select"
|
|
95
98
|
/>
|
|
96
99
|
</ExamplePanel>
|
|
97
100
|
<ExamplePanel title="Async Single Select, Search Form Styling">
|
|
@@ -100,6 +103,7 @@ export default function AsyncPage () {
|
|
|
100
103
|
processLoadOptions={processLoadOptions}
|
|
101
104
|
useSearchFormStyle={true}
|
|
102
105
|
label={'Things'}
|
|
106
|
+
id="search-form-style-async-single-select"
|
|
103
107
|
/>
|
|
104
108
|
</ExamplePanel>
|
|
105
109
|
<ExamplePanel title="Async Multi Select, Search Form Styling">
|
|
@@ -108,12 +112,14 @@ export default function AsyncPage () {
|
|
|
108
112
|
processLoadOptions={processLoadOptions}
|
|
109
113
|
multiple={true}
|
|
110
114
|
useSearchFormStyle={true}
|
|
115
|
+
id="search-form-style-async-multi-select"
|
|
111
116
|
/>
|
|
112
117
|
</ExamplePanel>
|
|
113
118
|
<ExamplePanel title="Multiple Data Sets">
|
|
114
119
|
<AsyncSelect
|
|
115
120
|
loadOptions={loadMultipleDatasets}
|
|
116
121
|
optionSets={['Window', 'Console']}
|
|
122
|
+
id="async-multiple-datasets-select"
|
|
117
123
|
/>
|
|
118
124
|
</ExamplePanel>
|
|
119
125
|
<ExamplePanel title="Loading initial options asynchronously">
|
|
@@ -13,6 +13,7 @@ export default function CalendarSelectPage () {
|
|
|
13
13
|
format="MM-DD-YYYY"
|
|
14
14
|
valueLabel="Select Date OK?"
|
|
15
15
|
minDate={moment()}
|
|
16
|
+
id="calendar-select"
|
|
16
17
|
/>
|
|
17
18
|
</ExamplePanel>
|
|
18
19
|
<ExamplePanel title="Calendar Input">
|
|
@@ -23,6 +24,7 @@ export default function CalendarSelectPage () {
|
|
|
23
24
|
defaultValue="01/01/2019"
|
|
24
25
|
mask="99/99/9999"
|
|
25
26
|
maskChar=" "
|
|
27
|
+
id="calendar-input"
|
|
26
28
|
ariaHidden={true}
|
|
27
29
|
ariaLabelledBy="calendar-input-label"
|
|
28
30
|
ariaDescription="Format: MM/DD/YYYY"
|
|
@@ -36,6 +38,7 @@ export default function CalendarSelectPage () {
|
|
|
36
38
|
mask="99/99/9999"
|
|
37
39
|
maskChar=" "
|
|
38
40
|
disabled
|
|
41
|
+
id="calendar-input-disabled"
|
|
39
42
|
/>
|
|
40
43
|
</ExamplePanel>
|
|
41
44
|
<ExamplePanel title="Defaultable Calendar Select">
|
|
@@ -44,12 +47,14 @@ export default function CalendarSelectPage () {
|
|
|
44
47
|
valueLabel="Select Date OK?"
|
|
45
48
|
minDate={moment()}
|
|
46
49
|
defaultValue={moment().add(364, 'day')}
|
|
50
|
+
id="defaultable-calendar-select"
|
|
47
51
|
/>
|
|
48
52
|
</ExamplePanel>
|
|
49
53
|
<ExamplePanel title="Calendar Range Select">
|
|
50
54
|
<CalendarRangeSelect
|
|
51
55
|
format="MM-DD-YYYY"
|
|
52
56
|
valueLabel="Select Date Range"
|
|
57
|
+
id="calendar-range-select"
|
|
53
58
|
/>
|
|
54
59
|
</ExamplePanel>
|
|
55
60
|
</Page>
|
|
@@ -13,7 +13,17 @@ const basicOptions = [
|
|
|
13
13
|
{ value: 3, label: 'Three', optionSet: 'First' },
|
|
14
14
|
{ value: 4, label: 'Four', disabled: true, optionSet: 'Second' },
|
|
15
15
|
{ value: 5, label: 'Five', optionSet: 'Second' },
|
|
16
|
-
{ value: 6, label: 'Six', optionSet: 'Second' }
|
|
16
|
+
{ value: 6, label: 'Six', optionSet: 'Second' },
|
|
17
|
+
{ value: 7, label: 'Seven', optionSet: 'Second' },
|
|
18
|
+
{ value: 8, label: 'Eight', optionSet: 'Second' },
|
|
19
|
+
{ value: 9, label: 'Nine', optionSet: 'Second' },
|
|
20
|
+
{ value: 10, label: 'Ten', optionSet: 'Second' },
|
|
21
|
+
{ value: 11, label: 'Eleven', optionSet: 'Second' },
|
|
22
|
+
{ value: 12, label: 'Twelve', optionSet: 'Second' },
|
|
23
|
+
{ value: 13, label: 'Thirteen', optionSet: 'Second' },
|
|
24
|
+
{ value: 14, label: 'Fourteen', optionSet: 'Second' },
|
|
25
|
+
{ value: 15, label: 'Fifteen', optionSet: 'Second' },
|
|
26
|
+
{ value: 16, label: 'Sixteen', optionSet: 'Second' },
|
|
17
27
|
];
|
|
18
28
|
|
|
19
29
|
const customOptions = [
|
|
@@ -112,8 +122,9 @@ export default function SelectPage () {
|
|
|
112
122
|
<ExamplePanel title="Basic Select">
|
|
113
123
|
<SingleSelect
|
|
114
124
|
options={basicOptions}
|
|
115
|
-
value={
|
|
125
|
+
value={13}
|
|
116
126
|
ariaLabel="Basic select label"
|
|
127
|
+
id="basic-select"
|
|
117
128
|
/>
|
|
118
129
|
</ExamplePanel>
|
|
119
130
|
<ExamplePanel title="Selects with multiple sets">
|
|
@@ -124,6 +135,7 @@ export default function SelectPage () {
|
|
|
124
135
|
options={multipleSetOptions}
|
|
125
136
|
optionSets={['Set 1', 'Set 2']}
|
|
126
137
|
value={0}
|
|
138
|
+
id="multiple-sets-select"
|
|
127
139
|
/>
|
|
128
140
|
</div>
|
|
129
141
|
</label>
|
|
@@ -136,6 +148,7 @@ export default function SelectPage () {
|
|
|
136
148
|
options={multipleSetOptions}
|
|
137
149
|
optionSets={['Set 1', 'Set 2']}
|
|
138
150
|
value={[0]}
|
|
151
|
+
id="multi-select-multiple-sets"
|
|
139
152
|
/>
|
|
140
153
|
</div>
|
|
141
154
|
</label>
|
|
@@ -146,6 +159,7 @@ export default function SelectPage () {
|
|
|
146
159
|
value="1"
|
|
147
160
|
filterable={true}
|
|
148
161
|
onChangeText={(t) => console.log(t)}
|
|
162
|
+
id="filterable-select"
|
|
149
163
|
/>
|
|
150
164
|
</ExamplePanel>
|
|
151
165
|
<ExamplePanel title="Custom Option Select">
|
|
@@ -153,6 +167,7 @@ export default function SelectPage () {
|
|
|
153
167
|
options={customOptions}
|
|
154
168
|
renderOptionLabel={renderCustomOption}
|
|
155
169
|
renderValueLabel={renderCustomValue}
|
|
170
|
+
id="custom-option-select"
|
|
156
171
|
/>
|
|
157
172
|
</ExamplePanel>
|
|
158
173
|
<ExamplePanel title="Disabled Select">
|
|
@@ -160,6 +175,7 @@ export default function SelectPage () {
|
|
|
160
175
|
options={basicOptions}
|
|
161
176
|
value="1"
|
|
162
177
|
disabled={true}
|
|
178
|
+
id="disabled-select"
|
|
163
179
|
/>
|
|
164
180
|
</ExamplePanel>
|
|
165
181
|
<ExamplePanel title="Multiple Select">
|
|
@@ -168,6 +184,7 @@ export default function SelectPage () {
|
|
|
168
184
|
placeholder="Choices"
|
|
169
185
|
value={[1]}
|
|
170
186
|
ariaLabel="Multi select label"
|
|
187
|
+
id="multiple-select"
|
|
171
188
|
/>
|
|
172
189
|
</ExamplePanel>
|
|
173
190
|
<ExamplePanel title="Tagbox Value Select">
|
|
@@ -175,6 +192,7 @@ export default function SelectPage () {
|
|
|
175
192
|
options={basicOptions}
|
|
176
193
|
placeholder="Choices"
|
|
177
194
|
value={[1]}
|
|
195
|
+
id="tagbox-value-select"
|
|
178
196
|
/>
|
|
179
197
|
</ExamplePanel>
|
|
180
198
|
<ExamplePanel title="Tagbox Value Disabled Select">
|
|
@@ -183,6 +201,7 @@ export default function SelectPage () {
|
|
|
183
201
|
placeholder="Choices"
|
|
184
202
|
value={[1, 2]}
|
|
185
203
|
disabled={true}
|
|
204
|
+
id="disabled-tagbox-value-select"
|
|
186
205
|
/>
|
|
187
206
|
</ExamplePanel>
|
|
188
207
|
<ExamplePanel title="Tagbox Value Not Filterable">
|
|
@@ -190,6 +209,8 @@ export default function SelectPage () {
|
|
|
190
209
|
options={basicOptions}
|
|
191
210
|
placeholder="Choices"
|
|
192
211
|
filterable={false}
|
|
212
|
+
id="not-filterable-tagbox-value-select"
|
|
213
|
+
|
|
193
214
|
/>
|
|
194
215
|
</ExamplePanel>
|
|
195
216
|
<ExamplePanel title="Tagbox Menu Select">
|
|
@@ -197,6 +218,7 @@ export default function SelectPage () {
|
|
|
197
218
|
options={hugeOptions}
|
|
198
219
|
valueLabel="Choices"
|
|
199
220
|
value={[1]}
|
|
221
|
+
id="tagbox-menu-select"
|
|
200
222
|
/>
|
|
201
223
|
</ExamplePanel>
|
|
202
224
|
<ExamplePanel title="Disabled Tagbox Menu Select">
|
|
@@ -205,6 +227,7 @@ export default function SelectPage () {
|
|
|
205
227
|
disabled={true}
|
|
206
228
|
valueLabel="Choices"
|
|
207
229
|
value={[1]}
|
|
230
|
+
id="disabled-tagbox-menu-select"
|
|
208
231
|
/>
|
|
209
232
|
</ExamplePanel>
|
|
210
233
|
<ExamplePanel title="Badge Menu Select">
|
|
@@ -212,6 +235,7 @@ export default function SelectPage () {
|
|
|
212
235
|
options={customOptions}
|
|
213
236
|
renderOptionLabel={renderCustomOption}
|
|
214
237
|
valueLabel="Choices"
|
|
238
|
+
id="badge-menu-select"
|
|
215
239
|
/>
|
|
216
240
|
</ExamplePanel>
|
|
217
241
|
<ExamplePanel title="Disabled Badge Menu Select">
|
|
@@ -220,6 +244,7 @@ export default function SelectPage () {
|
|
|
220
244
|
disabled={true}
|
|
221
245
|
renderOptionLabel={renderCustomOption}
|
|
222
246
|
valueLabel="Choices"
|
|
247
|
+
id="disabled-badge-menu-select"
|
|
223
248
|
/>
|
|
224
249
|
</ExamplePanel>
|
|
225
250
|
<ExamplePanel title="Programmatic Manipulation">
|
|
@@ -228,12 +253,14 @@ export default function SelectPage () {
|
|
|
228
253
|
<ExamplePanel title="Custom Option Classname">
|
|
229
254
|
<MultiSelect
|
|
230
255
|
options={customClassNameOptions}
|
|
256
|
+
id="custom-option-classname-select"
|
|
231
257
|
/>
|
|
232
258
|
</ExamplePanel>
|
|
233
259
|
<ExamplePanel title="Collapsible Multiselect">
|
|
234
260
|
<TagBoxMenuSelect
|
|
235
261
|
options={collapsibleOptions}
|
|
236
262
|
collapsibleOptions={[1, 3]}
|
|
263
|
+
id="collapsible-multiselect"
|
|
237
264
|
/>
|
|
238
265
|
</ExamplePanel>
|
|
239
266
|
</Page>
|
|
@@ -144,7 +144,8 @@ function AsyncSelect(props) {
|
|
|
144
144
|
processLoadOptions: props.processLoadOptions,
|
|
145
145
|
renderValueLabel: props.renderValueLabel,
|
|
146
146
|
renderOptionLabel: props.renderOptionLabel,
|
|
147
|
-
value: props.value
|
|
147
|
+
value: props.value,
|
|
148
|
+
id: props.id
|
|
148
149
|
}));
|
|
149
150
|
}
|
|
150
151
|
|
|
@@ -182,5 +183,6 @@ AsyncSelect.propTypes = {
|
|
|
182
183
|
renderOptionLabel: _propTypes2.default.func,
|
|
183
184
|
renderValueLabel: _propTypes2.default.func,
|
|
184
185
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array, _propTypes2.default.object]),
|
|
185
|
-
ValueComponent: _propTypes2.default.func
|
|
186
|
+
ValueComponent: _propTypes2.default.func,
|
|
187
|
+
id: _propTypes2.default.string
|
|
186
188
|
};
|
|
@@ -59,7 +59,8 @@ function BadgeMultiSelect(props) {
|
|
|
59
59
|
onClose: props.onClose,
|
|
60
60
|
options: props.options,
|
|
61
61
|
renderOptionLabel: props.renderOptionLabel,
|
|
62
|
-
valueLabel: props.valueLabel
|
|
62
|
+
valueLabel: props.valueLabel,
|
|
63
|
+
id: props.id
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -74,5 +75,6 @@ BadgeMultiSelect.propTypes = {
|
|
|
74
75
|
options: _propTypes2.default.array.isRequired,
|
|
75
76
|
renderOptionLabel: _propTypes2.default.func,
|
|
76
77
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
77
|
-
valueLabel: _propTypes2.default.string.isRequired
|
|
78
|
+
valueLabel: _propTypes2.default.string.isRequired,
|
|
79
|
+
id: _propTypes2.default.string
|
|
78
80
|
};
|
|
@@ -63,7 +63,9 @@ var CalendarInput = exports.CalendarInput = function CalendarInput(props) {
|
|
|
63
63
|
MenuComponent: CalendarSelectMenuWrap,
|
|
64
64
|
ValueComponent: InputWrap,
|
|
65
65
|
valueAdapter: valueAdapter
|
|
66
|
-
}, restProps
|
|
66
|
+
}, restProps, {
|
|
67
|
+
id: props.id
|
|
68
|
+
}));
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
var CalendarSelectMenuWrap = exports.CalendarSelectMenuWrap = function (_PureComponent) {
|
|
@@ -204,7 +206,8 @@ CalendarInput.propTypes = {
|
|
|
204
206
|
/**
|
|
205
207
|
onChange function to get value
|
|
206
208
|
*/
|
|
207
|
-
onChange: _propTypes2.default.func
|
|
209
|
+
onChange: _propTypes2.default.func,
|
|
210
|
+
id: _propTypes2.default.string
|
|
208
211
|
};
|
|
209
212
|
|
|
210
213
|
CalendarInput.defaultProps = {
|
|
@@ -133,7 +133,8 @@ CalendarRangeSelect.propTypes = {
|
|
|
133
133
|
/**
|
|
134
134
|
Component to display the Value
|
|
135
135
|
*/
|
|
136
|
-
ValueComponent: _propTypes2.default.func
|
|
136
|
+
ValueComponent: _propTypes2.default.func,
|
|
137
|
+
id: _propTypes2.default.string
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
CalendarRangeSelect.defaultProps = {
|
|
@@ -67,7 +67,9 @@ function CalendarSelect(props) {
|
|
|
67
67
|
renderValueLabel: renderValueLabel(format, valueLabel),
|
|
68
68
|
value: value || null,
|
|
69
69
|
valueAdapter: valueAdapter
|
|
70
|
-
}, restProps
|
|
70
|
+
}, restProps, {
|
|
71
|
+
id: props.id
|
|
72
|
+
}));
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
CalendarSelect.propTypes = {
|
|
@@ -83,7 +85,8 @@ CalendarSelect.propTypes = {
|
|
|
83
85
|
Label displayed if no value is selected
|
|
84
86
|
*/
|
|
85
87
|
valueLabel: _propTypes2.default.string,
|
|
86
|
-
ValueComponent: _propTypes2.default.func.isRequired
|
|
88
|
+
ValueComponent: _propTypes2.default.func.isRequired,
|
|
89
|
+
id: _propTypes2.default.string
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
CalendarSelect.defaultProps = {
|
|
@@ -63,7 +63,8 @@ function MultiSelect(props) {
|
|
|
63
63
|
value: props.value,
|
|
64
64
|
valueAdapter: valueAdapter,
|
|
65
65
|
ValueComponent: props.ValueComponent,
|
|
66
|
-
collapsibleOptions: props.collapsibleOptions
|
|
66
|
+
collapsibleOptions: props.collapsibleOptions,
|
|
67
|
+
id: props.id
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -83,7 +84,8 @@ MultiSelect.propTypes = {
|
|
|
83
84
|
renderOptionLabel: _propTypes2.default.func,
|
|
84
85
|
renderValueLabel: _propTypes2.default.func,
|
|
85
86
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
86
|
-
ValueComponent: _propTypes2.default.func.isRequired
|
|
87
|
+
ValueComponent: _propTypes2.default.func.isRequired,
|
|
88
|
+
id: _propTypes2.default.string
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
MultiSelect.defaultProps = {
|
|
@@ -181,6 +181,13 @@ var OptionListSet = function (_Component) {
|
|
|
181
181
|
renderedOptions
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
|
+
}, {
|
|
185
|
+
key: 'componentDidMount',
|
|
186
|
+
value: function componentDidMount() {
|
|
187
|
+
if (this.props.reference && this.props.reference.current && this.props.reference.current.querySelector('[aria-selected=true]')) {
|
|
188
|
+
this.props.reference.current.querySelector('[aria-selected=true]').scrollIntoView({ block: 'nearest' });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
184
191
|
}, {
|
|
185
192
|
key: 'render',
|
|
186
193
|
value: function render() {
|
|
@@ -815,7 +815,7 @@ var SelectCore = function (_Component) {
|
|
|
815
815
|
value: function render() {
|
|
816
816
|
return _react2.default.createElement(
|
|
817
817
|
'div',
|
|
818
|
-
{ className: _SelectCore2.default.select },
|
|
818
|
+
{ className: _SelectCore2.default.select, id: this.props.id },
|
|
819
819
|
this.renderValue(),
|
|
820
820
|
(this.state.isOpen || this.props.alwaysOpen) && this.renderMenu()
|
|
821
821
|
);
|
|
@@ -958,7 +958,10 @@ SelectCore.propTypes = {
|
|
|
958
958
|
filterable: _propTypes2.default.bool,
|
|
959
959
|
onOptionsFiltered: _propTypes2.default.func,
|
|
960
960
|
onChangeText: _propTypes2.default.func,
|
|
961
|
-
collapsibleOptions: _propTypes2.default.array
|
|
961
|
+
collapsibleOptions: _propTypes2.default.array,
|
|
962
|
+
|
|
963
|
+
// add a unique id for testing purposes and accessibility
|
|
964
|
+
id: _propTypes2.default.string
|
|
962
965
|
|
|
963
966
|
};
|
|
964
967
|
|
|
@@ -75,7 +75,8 @@ function SingleSelect(props) {
|
|
|
75
75
|
renderValueLabel: props.renderValueLabel,
|
|
76
76
|
renderOptionLabel: props.renderOptionLabel,
|
|
77
77
|
unselectOnClick: props.unselectOnClick,
|
|
78
|
-
value: props.value
|
|
78
|
+
value: props.value,
|
|
79
|
+
id: props.id
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -100,7 +101,8 @@ SingleSelect.propTypes = {
|
|
|
100
101
|
unselectOnClick: _propTypes2.default.bool,
|
|
101
102
|
optionSets: _propTypes2.default.array,
|
|
102
103
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
|
103
|
-
ValueComponent: _propTypes2.default.func
|
|
104
|
+
ValueComponent: _propTypes2.default.func,
|
|
105
|
+
id: _propTypes2.default.string
|
|
104
106
|
};
|
|
105
107
|
|
|
106
108
|
SingleSelect.defaultProps = {
|
|
@@ -54,7 +54,8 @@ function TabbedSelect(props) {
|
|
|
54
54
|
onOpen: props.onOpen,
|
|
55
55
|
onClose: props.onClose,
|
|
56
56
|
valueLabel: props.valueLabel,
|
|
57
|
-
value: props.value
|
|
57
|
+
value: props.value,
|
|
58
|
+
id: props.id
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -68,7 +69,8 @@ TabbedSelect.propTypes = {
|
|
|
68
69
|
onOpen: _propTypes2.default.func,
|
|
69
70
|
options: _propTypes2.default.array.isRequired,
|
|
70
71
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
71
|
-
valueLabel: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array])
|
|
72
|
+
valueLabel: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
73
|
+
id: _propTypes2.default.string
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
// Tabs -> {name: '', choices: [{label, value}]}
|
|
@@ -60,7 +60,8 @@ function TagBoxMenuSelect(props) {
|
|
|
60
60
|
renderOptionLabel: props.renderOptionLabel,
|
|
61
61
|
value: props.value,
|
|
62
62
|
ValueComponent: props.ValueComponent,
|
|
63
|
-
valueLabel: props.valueLabel || 'Choices'
|
|
63
|
+
valueLabel: props.valueLabel || 'Choices',
|
|
64
|
+
id: props.id
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -77,7 +78,8 @@ TagBoxMenuSelect.propTypes = {
|
|
|
77
78
|
renderValueLabel: _propTypes2.default.func,
|
|
78
79
|
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
79
80
|
valueLabel: _propTypes2.default.string,
|
|
80
|
-
ValueComponent: _propTypes2.default.func.isRequired
|
|
81
|
+
ValueComponent: _propTypes2.default.func.isRequired,
|
|
82
|
+
id: _propTypes2.default.string
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
TagBoxMenuSelect.defaultProps = {
|
|
@@ -63,7 +63,8 @@ function TagBoxValueSelect(props) {
|
|
|
63
63
|
options: props.options,
|
|
64
64
|
renderValueLabel: props.renderValueLabel,
|
|
65
65
|
renderOptionLabel: props.renderOptionLabel,
|
|
66
|
-
disabled: props.disabled
|
|
66
|
+
disabled: props.disabled,
|
|
67
|
+
id: props.id
|
|
67
68
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -83,7 +84,8 @@ TagBoxValueSelect.propTypes = {
|
|
|
83
84
|
menuContainerClassName: _propTypes2.default.string,
|
|
84
85
|
menuContainerText: _propTypes2.default.string,
|
|
85
86
|
menuContainerTextClassName: _propTypes2.default.string,
|
|
86
|
-
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array])
|
|
87
|
+
value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.array]),
|
|
88
|
+
id: _propTypes2.default.string
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
TagBoxValueSelect.defaultProps = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestio/pam",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9-beta.0",
|
|
4
4
|
"description": "Nestio UI modules",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"homepage": "https://github.com/Nestio/pam#readme",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"classnames": "^2.2.5",
|
|
34
|
-
"lodash": "^4.
|
|
35
|
-
"moment": "^2.
|
|
34
|
+
"lodash": "^4.17.21",
|
|
35
|
+
"moment": "^2.29.4",
|
|
36
36
|
"prop-types": "^15.5.10",
|
|
37
37
|
"react-datepicker": "1.1.0",
|
|
38
38
|
"react-input-autosize": "2.2.1",
|
|
@@ -45,8 +45,6 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"babel-cli": "^6.11.4",
|
|
48
|
-
"react": "^16.2.0",
|
|
49
|
-
"react-dom": "^16.2.0",
|
|
50
48
|
"babel-core": "^6.10.4",
|
|
51
49
|
"babel-eslint": "^6.1.0",
|
|
52
50
|
"babel-loader": "^6.2.4",
|
|
@@ -61,10 +59,12 @@
|
|
|
61
59
|
"eslint-plugin-react": "^5.2.2",
|
|
62
60
|
"file-loader": "^0.11.2",
|
|
63
61
|
"identity-obj-proxy": "^3.0.0",
|
|
64
|
-
"jest": "20.0.4",
|
|
65
|
-
"node-sass": "4.
|
|
62
|
+
"jest": "^20.0.4",
|
|
63
|
+
"node-sass": "^4.14.1",
|
|
66
64
|
"null-loader": "^0.1.1",
|
|
67
65
|
"raf": "^3.4.0",
|
|
66
|
+
"react": "^16.2.0",
|
|
67
|
+
"react-dom": "^16.2.0",
|
|
68
68
|
"react-router-dom": "^4.1.2",
|
|
69
69
|
"sass-loader": "^7.0.1",
|
|
70
70
|
"sinon": "^1.17.4",
|
|
@@ -93,6 +93,7 @@ export default function AsyncSelect (props) {
|
|
|
93
93
|
renderValueLabel={props.renderValueLabel}
|
|
94
94
|
renderOptionLabel={props.renderOptionLabel}
|
|
95
95
|
value={props.value}
|
|
96
|
+
id={props.id}
|
|
96
97
|
/>
|
|
97
98
|
);
|
|
98
99
|
}
|
|
@@ -129,5 +130,6 @@ AsyncSelect.propTypes = {
|
|
|
129
130
|
renderOptionLabel: PropTypes.func,
|
|
130
131
|
renderValueLabel: PropTypes.func,
|
|
131
132
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array, PropTypes.object]),
|
|
132
|
-
ValueComponent: PropTypes.func
|
|
133
|
+
ValueComponent: PropTypes.func,
|
|
134
|
+
id: PropTypes.string,
|
|
133
135
|
};
|
|
@@ -33,6 +33,7 @@ export default function BadgeMultiSelect (props){
|
|
|
33
33
|
options={props.options}
|
|
34
34
|
renderOptionLabel={props.renderOptionLabel}
|
|
35
35
|
valueLabel={props.valueLabel}
|
|
36
|
+
id={props.id}
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
38
39
|
}
|
|
@@ -48,5 +49,6 @@ BadgeMultiSelect.propTypes = {
|
|
|
48
49
|
options: PropTypes.array.isRequired,
|
|
49
50
|
renderOptionLabel: PropTypes.func,
|
|
50
51
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
51
|
-
valueLabel: PropTypes.string.isRequired
|
|
52
|
+
valueLabel: PropTypes.string.isRequired,
|
|
53
|
+
id: PropTypes.string,
|
|
52
54
|
};
|
|
@@ -24,6 +24,7 @@ export const CalendarInput = (props) => {
|
|
|
24
24
|
ValueComponent={InputWrap}
|
|
25
25
|
valueAdapter={valueAdapter}
|
|
26
26
|
{...restProps}
|
|
27
|
+
id={props.id}
|
|
27
28
|
/>
|
|
28
29
|
);
|
|
29
30
|
};
|
|
@@ -147,7 +148,8 @@ CalendarInput.propTypes = {
|
|
|
147
148
|
/**
|
|
148
149
|
onChange function to get value
|
|
149
150
|
*/
|
|
150
|
-
onChange: PropTypes.func
|
|
151
|
+
onChange: PropTypes.func,
|
|
152
|
+
id: PropTypes.string,
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
CalendarInput.defaultProps = {
|
|
@@ -30,6 +30,7 @@ export default function CalendarSelect (props) {
|
|
|
30
30
|
value={value || null}
|
|
31
31
|
valueAdapter={valueAdapter}
|
|
32
32
|
{...restProps}
|
|
33
|
+
id={props.id}
|
|
33
34
|
/>
|
|
34
35
|
);
|
|
35
36
|
}
|
|
@@ -47,7 +48,8 @@ CalendarSelect.propTypes = {
|
|
|
47
48
|
Label displayed if no value is selected
|
|
48
49
|
*/
|
|
49
50
|
valueLabel: PropTypes.string,
|
|
50
|
-
ValueComponent: PropTypes.func.isRequired
|
|
51
|
+
ValueComponent: PropTypes.func.isRequired,
|
|
52
|
+
id: PropTypes.string
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
CalendarSelect.defaultProps = {
|
|
@@ -37,6 +37,7 @@ export default function MultiSelect (props){
|
|
|
37
37
|
valueAdapter={valueAdapter}
|
|
38
38
|
ValueComponent={props.ValueComponent}
|
|
39
39
|
collapsibleOptions={props.collapsibleOptions}
|
|
40
|
+
id={props.id}
|
|
40
41
|
/>
|
|
41
42
|
);
|
|
42
43
|
}
|
|
@@ -57,7 +58,8 @@ MultiSelect.propTypes = {
|
|
|
57
58
|
renderOptionLabel: PropTypes.func,
|
|
58
59
|
renderValueLabel: PropTypes.func,
|
|
59
60
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
60
|
-
ValueComponent: PropTypes.func.isRequired
|
|
61
|
+
ValueComponent: PropTypes.func.isRequired,
|
|
62
|
+
id: PropTypes.string,
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
MultiSelect.defaultProps = {
|
|
@@ -114,6 +114,12 @@ export default class OptionListSet extends Component {
|
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
componentDidMount() {
|
|
118
|
+
if (this.props.reference && this.props.reference.current && this.props.reference.current.querySelector('[aria-selected=true]')) {
|
|
119
|
+
this.props.reference.current.querySelector('[aria-selected=true]').scrollIntoView({ block: 'nearest' });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
117
123
|
render(){
|
|
118
124
|
if (this.props.isBelowMinLength) {
|
|
119
125
|
return this.renderMinLengthComponent();
|
|
@@ -641,7 +641,7 @@ class SelectCore extends Component {
|
|
|
641
641
|
|
|
642
642
|
render(){
|
|
643
643
|
return (
|
|
644
|
-
<div className={styles.select}>
|
|
644
|
+
<div className={styles.select} id={this.props.id}>
|
|
645
645
|
{ this.renderValue() }
|
|
646
646
|
{ (this.state.isOpen || this.props.alwaysOpen) && this.renderMenu() }
|
|
647
647
|
</div>
|
|
@@ -782,7 +782,10 @@ SelectCore.propTypes = {
|
|
|
782
782
|
filterable: PropTypes.bool,
|
|
783
783
|
onOptionsFiltered: PropTypes.func,
|
|
784
784
|
onChangeText: PropTypes.func,
|
|
785
|
-
collapsibleOptions: PropTypes.array
|
|
785
|
+
collapsibleOptions: PropTypes.array,
|
|
786
|
+
|
|
787
|
+
// add a unique id for testing purposes and accessibility
|
|
788
|
+
id: PropTypes.string,
|
|
786
789
|
|
|
787
790
|
};
|
|
788
791
|
|
|
@@ -46,6 +46,7 @@ export default function SingleSelect (props){
|
|
|
46
46
|
renderOptionLabel={props.renderOptionLabel}
|
|
47
47
|
unselectOnClick={props.unselectOnClick}
|
|
48
48
|
value={props.value}
|
|
49
|
+
id={props.id}
|
|
49
50
|
/>
|
|
50
51
|
);
|
|
51
52
|
}
|
|
@@ -71,7 +72,8 @@ SingleSelect.propTypes = {
|
|
|
71
72
|
unselectOnClick: PropTypes.bool,
|
|
72
73
|
optionSets: PropTypes.array,
|
|
73
74
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
74
|
-
ValueComponent: PropTypes.func
|
|
75
|
+
ValueComponent: PropTypes.func,
|
|
76
|
+
id: PropTypes.string,
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
SingleSelect.defaultProps = {
|
|
@@ -31,6 +31,7 @@ export default function TabbedSelect (props){
|
|
|
31
31
|
onClose={props.onClose}
|
|
32
32
|
valueLabel={props.valueLabel}
|
|
33
33
|
value={props.value}
|
|
34
|
+
id={props.id}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
}
|
|
@@ -45,7 +46,8 @@ TabbedSelect.propTypes = {
|
|
|
45
46
|
onOpen: PropTypes.func,
|
|
46
47
|
options: PropTypes.array.isRequired,
|
|
47
48
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
48
|
-
valueLabel: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array])
|
|
49
|
+
valueLabel: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
50
|
+
id: PropTypes.string,
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
// Tabs -> {name: '', choices: [{label, value}]}
|
|
@@ -34,6 +34,7 @@ export default function TagBoxMenuSelect (props) {
|
|
|
34
34
|
value={props.value}
|
|
35
35
|
ValueComponent={props.ValueComponent}
|
|
36
36
|
valueLabel={props.valueLabel || 'Choices'}
|
|
37
|
+
id={props.id}
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
40
|
}
|
|
@@ -51,7 +52,8 @@ TagBoxMenuSelect.propTypes = {
|
|
|
51
52
|
renderValueLabel: PropTypes.func,
|
|
52
53
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
53
54
|
valueLabel: PropTypes.string,
|
|
54
|
-
ValueComponent: PropTypes.func.isRequired
|
|
55
|
+
ValueComponent: PropTypes.func.isRequired,
|
|
56
|
+
id: PropTypes.string,
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
TagBoxMenuSelect.defaultProps = {
|
|
@@ -37,6 +37,7 @@ export default function TagBoxValueSelect (props) {
|
|
|
37
37
|
renderValueLabel={props.renderValueLabel}
|
|
38
38
|
renderOptionLabel={props.renderOptionLabel}
|
|
39
39
|
disabled={props.disabled}
|
|
40
|
+
id={props.id}
|
|
40
41
|
|
|
41
42
|
/>
|
|
42
43
|
);
|
|
@@ -58,6 +59,7 @@ TagBoxValueSelect.propTypes = {
|
|
|
58
59
|
menuContainerText: PropTypes.string,
|
|
59
60
|
menuContainerTextClassName: PropTypes.string,
|
|
60
61
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
62
|
+
id: PropTypes.string,
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
TagBoxValueSelect.defaultProps = {
|
|
@@ -29,6 +29,8 @@ beforeEach(function(){
|
|
|
29
29
|
getCollapsibleState: () => null,
|
|
30
30
|
toggleCollapsedValue: jest.fn()
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
Element.prototype.scrollIntoView = jest.fn();
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
describe('single option set', function(){
|
|
@@ -150,6 +152,7 @@ describe('keyboard functions', function() {
|
|
|
150
152
|
});
|
|
151
153
|
|
|
152
154
|
describe('move scrollbar position', function() {
|
|
155
|
+
const mockScrollIntoView = jest.fn();
|
|
153
156
|
|
|
154
157
|
const mockReference = {
|
|
155
158
|
current: {
|
|
@@ -159,12 +162,13 @@ describe('move scrollbar position', function() {
|
|
|
159
162
|
return {
|
|
160
163
|
nextSibling: {
|
|
161
164
|
offsetTop: 100,
|
|
162
|
-
offsetHeight: 50
|
|
165
|
+
offsetHeight: 50,
|
|
163
166
|
},
|
|
164
167
|
previousSibling: {
|
|
165
168
|
offsetTop: 0,
|
|
166
|
-
offsetHeight: 50
|
|
167
|
-
}
|
|
169
|
+
offsetHeight: 50,
|
|
170
|
+
},
|
|
171
|
+
scrollIntoView: mockScrollIntoView,
|
|
168
172
|
};
|
|
169
173
|
}
|
|
170
174
|
}
|
|
@@ -191,6 +195,15 @@ describe('move scrollbar position', function() {
|
|
|
191
195
|
expect(mockReference.current.scrollTop).toEqual(0);
|
|
192
196
|
});
|
|
193
197
|
|
|
198
|
+
it('should focus the active element on mount', function () {
|
|
199
|
+
jest.resetAllMocks();
|
|
200
|
+
|
|
201
|
+
defaultProps.reference = mockReference;
|
|
202
|
+
shallow(<OptionListSet {...defaultProps} />);
|
|
203
|
+
|
|
204
|
+
expect(mockScrollIntoView).toHaveBeenCalledTimes(1);
|
|
205
|
+
expect(mockScrollIntoView).toHaveBeenCalledWith({ block: 'nearest' });
|
|
206
|
+
});
|
|
194
207
|
});
|
|
195
208
|
|
|
196
209
|
|