@instructure/ui-simple-select 10.16.1-pr-snapshot-1744893671793 → 10.16.1-snapshot-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/CHANGELOG.md +1 -1
- package/es/SimpleSelect/__examples__/SimpleSelect.examples.js +27 -27
- package/es/SimpleSelect/__new-tests__/SimpleSelect.test.js +79 -104
- package/es/SimpleSelect/index.js +16 -22
- package/lib/SimpleSelect/__examples__/SimpleSelect.examples.js +28 -27
- package/lib/SimpleSelect/__new-tests__/SimpleSelect.test.js +119 -143
- package/lib/SimpleSelect/index.js +17 -22
- package/package.json +15 -15
- package/src/SimpleSelect/__examples__/SimpleSelect.examples.tsx +2 -0
- package/src/SimpleSelect/__new-tests__/SimpleSelect.test.tsx +1 -1
- package/src/SimpleSelect/index.tsx +5 -5
- package/src/SimpleSelect/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SimpleSelect/__examples__/SimpleSelect.examples.d.ts.map +1 -1
- package/types/SimpleSelect/index.d.ts +4 -4
- package/types/SimpleSelect/index.d.ts.map +1 -1
- package/types/SimpleSelect/props.d.ts +1 -1
- package/types/SimpleSelect/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
-
## [10.16.1-
|
6
|
+
## [10.16.1-snapshot-0](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-0) (2025-04-15)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-simple-select
|
9
9
|
|
@@ -22,54 +22,54 @@
|
|
22
22
|
* SOFTWARE.
|
23
23
|
*/
|
24
24
|
|
25
|
+
import React from 'react';
|
25
26
|
import { SimpleSelect } from '../../SimpleSelect';
|
26
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
27
27
|
export default {
|
28
28
|
sectionProp: 'size',
|
29
29
|
maxExamplesPerPage: 50,
|
30
30
|
propValues: {
|
31
|
-
children: [[
|
31
|
+
children: [[/*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
32
32
|
id: "0",
|
33
33
|
value: "0",
|
34
|
-
|
35
|
-
}, "
|
34
|
+
key: "0"
|
35
|
+
}, "Option one"), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
36
36
|
id: "1",
|
37
37
|
value: "1",
|
38
|
-
|
39
|
-
}, "
|
38
|
+
key: "1"
|
39
|
+
}, "Option two"), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
40
40
|
id: "2",
|
41
41
|
value: "2",
|
42
|
-
|
43
|
-
}, "
|
42
|
+
key: "2"
|
43
|
+
}, "Option three"), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
44
44
|
id: "3",
|
45
45
|
value: "3",
|
46
|
-
|
47
|
-
|
48
|
-
}, "
|
46
|
+
key: "3",
|
47
|
+
isDisabled: true
|
48
|
+
}, "Option four")], [/*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
49
49
|
id: "0",
|
50
50
|
value: "0",
|
51
|
-
|
52
|
-
}, "
|
51
|
+
key: "0"
|
52
|
+
}, "Item not in a group"), /*#__PURE__*/React.createElement(SimpleSelect.Group, {
|
53
53
|
id: "1",
|
54
54
|
renderLabel: "Group one",
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}, "
|
55
|
+
key: "1"
|
56
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
57
|
+
id: "2",
|
58
|
+
value: "2",
|
59
|
+
key: "2"
|
60
|
+
}, "Grouped item one")), /*#__PURE__*/React.createElement(SimpleSelect.Group, {
|
61
61
|
id: "3",
|
62
62
|
renderLabel: "Group two",
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}, "
|
63
|
+
key: "3"
|
64
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
65
|
+
id: "4",
|
66
|
+
value: "4",
|
67
|
+
key: "4"
|
68
|
+
}, "Grouped item two")), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
69
69
|
id: "5",
|
70
70
|
value: "5",
|
71
|
-
|
72
|
-
}, "
|
71
|
+
key: "5"
|
72
|
+
}, "Item not in a group two")]]
|
73
73
|
},
|
74
74
|
excludeProps: ['isOptionContentAppliedToInput'],
|
75
75
|
getComponentProps: () => {
|
@@ -23,7 +23,7 @@ var _SimpleSelect, _SimpleSelect2, _SimpleSelect3, _SimpleSelect4, _SimpleSelect
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24
24
|
* SOFTWARE.
|
25
25
|
*/
|
26
|
-
|
26
|
+
import React from 'react';
|
27
27
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
28
28
|
import { vi, it } from 'vitest';
|
29
29
|
import userEvent from '@testing-library/user-event';
|
@@ -35,13 +35,12 @@ import { IconCheckSolid } from '@instructure/ui-icons';
|
|
35
35
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
36
36
|
import SimpleSelectExamples from '../__examples__/SimpleSelect.examples';
|
37
37
|
import SimpleSelect from '../index';
|
38
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
39
38
|
const defaultOptions = ['foo', 'bar', 'baz'];
|
40
|
-
const getOptions = disabled => defaultOptions.map(opt =>
|
39
|
+
const getOptions = disabled => defaultOptions.map(opt => /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
41
40
|
id: opt,
|
41
|
+
key: opt,
|
42
42
|
value: opt,
|
43
|
-
isDisabled: opt === disabled
|
44
|
-
children: opt
|
43
|
+
isDisabled: opt === disabled
|
45
44
|
}, opt));
|
46
45
|
describe('<SimpleSelect />', () => {
|
47
46
|
let consoleErrorMock;
|
@@ -53,10 +52,9 @@ describe('<SimpleSelect />', () => {
|
|
53
52
|
consoleErrorMock.mockRestore();
|
54
53
|
});
|
55
54
|
it('should render an input and a list', async () => {
|
56
|
-
render(
|
57
|
-
renderLabel: "Choose an option"
|
58
|
-
|
59
|
-
}));
|
55
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
56
|
+
renderLabel: "Choose an option"
|
57
|
+
}, getOptions()));
|
60
58
|
const input = screen.getByLabelText('Choose an option');
|
61
59
|
const listInitial = screen.queryByRole('listbox');
|
62
60
|
expect(listInitial).not.toBeInTheDocument();
|
@@ -68,32 +66,25 @@ describe('<SimpleSelect />', () => {
|
|
68
66
|
});
|
69
67
|
});
|
70
68
|
it('should render groups', async () => {
|
71
|
-
render(_SimpleSelect || (_SimpleSelect =
|
72
|
-
renderLabel: "Choose an option"
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
})
|
91
|
-
}), _jsx(SimpleSelect.Option, {
|
92
|
-
id: "3",
|
93
|
-
value: "3",
|
94
|
-
children: "ungrouped option two"
|
95
|
-
})]
|
96
|
-
})));
|
69
|
+
render(_SimpleSelect || (_SimpleSelect = /*#__PURE__*/React.createElement(SimpleSelect, {
|
70
|
+
renderLabel: "Choose an option"
|
71
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
72
|
+
id: "0",
|
73
|
+
value: "0"
|
74
|
+
}, "ungrouped option one"), /*#__PURE__*/React.createElement(SimpleSelect.Group, {
|
75
|
+
renderLabel: "Group one"
|
76
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
77
|
+
id: "1",
|
78
|
+
value: "1"
|
79
|
+
}, "grouped option one")), /*#__PURE__*/React.createElement(SimpleSelect.Group, {
|
80
|
+
renderLabel: "Group two"
|
81
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
82
|
+
id: "2",
|
83
|
+
value: "2"
|
84
|
+
}, "grouped option two")), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
85
|
+
id: "3",
|
86
|
+
value: "3"
|
87
|
+
}, "ungrouped option two"))));
|
97
88
|
const input = screen.getByLabelText('Choose an option');
|
98
89
|
await userEvent.click(input);
|
99
90
|
await waitFor(() => {
|
@@ -106,16 +97,12 @@ describe('<SimpleSelect />', () => {
|
|
106
97
|
});
|
107
98
|
});
|
108
99
|
it('should ignore invalid children', async () => {
|
109
|
-
render(_SimpleSelect2 || (_SimpleSelect2 =
|
110
|
-
renderLabel: "Choose an option"
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}), _jsx("div", {
|
116
|
-
children: "invalid"
|
117
|
-
})]
|
118
|
-
})));
|
100
|
+
render(_SimpleSelect2 || (_SimpleSelect2 = /*#__PURE__*/React.createElement(SimpleSelect, {
|
101
|
+
renderLabel: "Choose an option"
|
102
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
103
|
+
id: "0",
|
104
|
+
value: 0
|
105
|
+
}, "valid"), /*#__PURE__*/React.createElement("div", null, "invalid"))));
|
119
106
|
const input = screen.getByLabelText('Choose an option');
|
120
107
|
await userEvent.click(input);
|
121
108
|
await waitFor(() => {
|
@@ -126,11 +113,10 @@ describe('<SimpleSelect />', () => {
|
|
126
113
|
});
|
127
114
|
it('should fire onFocus when input gains focus', async () => {
|
128
115
|
const onFocus = vi.fn();
|
129
|
-
render(
|
116
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
130
117
|
renderLabel: "Choose an option",
|
131
|
-
onFocus: onFocus
|
132
|
-
|
133
|
-
}));
|
118
|
+
onFocus: onFocus
|
119
|
+
}, getOptions()));
|
134
120
|
const input = screen.getByLabelText('Choose an option');
|
135
121
|
input.focus();
|
136
122
|
await waitFor(() => {
|
@@ -139,7 +125,7 @@ describe('<SimpleSelect />', () => {
|
|
139
125
|
});
|
140
126
|
describe('input', () => {
|
141
127
|
it('should render with a custom id if given', async () => {
|
142
|
-
render(_SimpleSelect3 || (_SimpleSelect3 =
|
128
|
+
render(_SimpleSelect3 || (_SimpleSelect3 = /*#__PURE__*/React.createElement(SimpleSelect, {
|
143
129
|
renderLabel: "Choose an option",
|
144
130
|
id: "customSelect"
|
145
131
|
})));
|
@@ -147,7 +133,7 @@ describe('<SimpleSelect />', () => {
|
|
147
133
|
expect(input).toHaveAttribute('id', 'customSelect');
|
148
134
|
});
|
149
135
|
it('should always render readonly', async () => {
|
150
|
-
render(_SimpleSelect4 || (_SimpleSelect4 =
|
136
|
+
render(_SimpleSelect4 || (_SimpleSelect4 = /*#__PURE__*/React.createElement(SimpleSelect, {
|
151
137
|
renderLabel: "Choose an option",
|
152
138
|
interaction: "enabled"
|
153
139
|
})));
|
@@ -156,7 +142,7 @@ describe('<SimpleSelect />', () => {
|
|
156
142
|
expect(input).not.toHaveAttribute('disabled');
|
157
143
|
});
|
158
144
|
it('should render disabled when interaction="disabled"', async () => {
|
159
|
-
render(_SimpleSelect5 || (_SimpleSelect5 =
|
145
|
+
render(_SimpleSelect5 || (_SimpleSelect5 = /*#__PURE__*/React.createElement(SimpleSelect, {
|
160
146
|
renderLabel: "Choose an option",
|
161
147
|
interaction: "disabled"
|
162
148
|
})));
|
@@ -165,7 +151,7 @@ describe('<SimpleSelect />', () => {
|
|
165
151
|
expect(input).not.toHaveAttribute('readonly');
|
166
152
|
});
|
167
153
|
it('should render required when isRequired={true}', async () => {
|
168
|
-
render(_SimpleSelect6 || (_SimpleSelect6 =
|
154
|
+
render(_SimpleSelect6 || (_SimpleSelect6 = /*#__PURE__*/React.createElement(SimpleSelect, {
|
169
155
|
renderLabel: "Choose an option",
|
170
156
|
isRequired: true
|
171
157
|
})));
|
@@ -173,55 +159,49 @@ describe('<SimpleSelect />', () => {
|
|
173
159
|
expect(input).toHaveAttribute('required');
|
174
160
|
});
|
175
161
|
it('should allow assistive text', async () => {
|
176
|
-
render(
|
162
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
177
163
|
renderLabel: "Choose an option",
|
178
|
-
assistiveText: "hello world"
|
179
|
-
|
180
|
-
}));
|
164
|
+
assistiveText: "hello world"
|
165
|
+
}, getOptions()));
|
181
166
|
const input = screen.getByLabelText('Choose an option');
|
182
167
|
const assistiveText = screen.getByText('hello world');
|
183
168
|
const assistiveTextID = assistiveText.getAttribute('id');
|
184
169
|
expect(input).toHaveAttribute('aria-describedby', assistiveTextID);
|
185
170
|
});
|
186
171
|
it('should allow custom props to pass through', async () => {
|
187
|
-
render(
|
172
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
188
173
|
renderLabel: "Choose an option",
|
189
|
-
"data-custom-attr": "true"
|
190
|
-
|
191
|
-
}));
|
174
|
+
"data-custom-attr": "true"
|
175
|
+
}, getOptions()));
|
192
176
|
const input = screen.getByLabelText('Choose an option');
|
193
177
|
expect(input).toHaveAttribute('data-custom-attr', 'true');
|
194
178
|
});
|
195
179
|
it('should provide a ref to the input element', async () => {
|
196
180
|
const inputRef = vi.fn();
|
197
|
-
render(
|
181
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
198
182
|
renderLabel: "Choose an option",
|
199
|
-
inputRef: inputRef
|
200
|
-
|
201
|
-
}));
|
183
|
+
inputRef: inputRef
|
184
|
+
}, getOptions()));
|
202
185
|
const input = screen.getByLabelText('Choose an option');
|
203
186
|
expect(inputRef).toHaveBeenCalledWith(input);
|
204
187
|
});
|
205
188
|
});
|
206
189
|
it('should render icons before option and call renderBeforeLabel callback with necessary props', async () => {
|
207
|
-
const renderBeforeLabel = vi.fn(() => _IconCheckSolid || (_IconCheckSolid =
|
190
|
+
const renderBeforeLabel = vi.fn(() => _IconCheckSolid || (_IconCheckSolid = /*#__PURE__*/React.createElement(IconCheckSolid, {
|
208
191
|
"data-testid": "option-icon"
|
209
192
|
})));
|
210
|
-
render(
|
211
|
-
renderLabel: "Choose an option"
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
children: "option two"
|
223
|
-
})]
|
224
|
-
}));
|
193
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
194
|
+
renderLabel: "Choose an option"
|
195
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
196
|
+
id: "option-1",
|
197
|
+
value: "1",
|
198
|
+
isDisabled: true,
|
199
|
+
renderBeforeLabel: renderBeforeLabel
|
200
|
+
}, "option one"), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
201
|
+
id: "option-2",
|
202
|
+
value: "2",
|
203
|
+
renderBeforeLabel: renderBeforeLabel
|
204
|
+
}, "option two")));
|
225
205
|
const input = screen.getByLabelText('Choose an option');
|
226
206
|
await userEvent.click(input);
|
227
207
|
await waitFor(() => {
|
@@ -252,10 +232,9 @@ describe('<SimpleSelect />', () => {
|
|
252
232
|
});
|
253
233
|
describe('list', () => {
|
254
234
|
it('should set aria-disabled on options when isDisabled={true}', async () => {
|
255
|
-
render(
|
256
|
-
renderLabel: "Choose an option"
|
257
|
-
|
258
|
-
}));
|
235
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
236
|
+
renderLabel: "Choose an option"
|
237
|
+
}, getOptions(defaultOptions[2])));
|
259
238
|
const input = screen.getByLabelText('Choose an option');
|
260
239
|
await userEvent.click(input);
|
261
240
|
await waitFor(() => {
|
@@ -266,11 +245,10 @@ describe('<SimpleSelect />', () => {
|
|
266
245
|
});
|
267
246
|
it('should provide a ref to the list element', async () => {
|
268
247
|
const listRef = vi.fn();
|
269
|
-
render(
|
248
|
+
render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
270
249
|
renderLabel: "Choose an option",
|
271
|
-
listRef: listRef
|
272
|
-
|
273
|
-
}));
|
250
|
+
listRef: listRef
|
251
|
+
}, getOptions()));
|
274
252
|
const input = screen.getByLabelText('Choose an option');
|
275
253
|
await userEvent.click(input);
|
276
254
|
await waitFor(() => {
|
@@ -293,16 +271,15 @@ describe('<SimpleSelect />', () => {
|
|
293
271
|
describe('children', () => {
|
294
272
|
const initialOptions = ['foo', 'bar'];
|
295
273
|
const updatedOptions = ['bar', 'baz'];
|
296
|
-
const getOptions = options => options.map(opt =>
|
274
|
+
const getOptions = options => options.map(opt => /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
297
275
|
id: opt,
|
298
|
-
|
299
|
-
|
276
|
+
key: opt,
|
277
|
+
value: opt
|
300
278
|
}, opt));
|
301
279
|
const renderSimpleSelect = options => {
|
302
|
-
return render(
|
303
|
-
renderLabel: "Choose an option"
|
304
|
-
|
305
|
-
}));
|
280
|
+
return render(/*#__PURE__*/React.createElement(SimpleSelect, {
|
281
|
+
renderLabel: "Choose an option"
|
282
|
+
}, getOptions(options)));
|
306
283
|
};
|
307
284
|
it('should clear selection if selected option does not exist in updated options', () => {
|
308
285
|
const _renderSimpleSelect = renderSimpleSelect(initialOptions),
|
@@ -316,10 +293,9 @@ describe('<SimpleSelect />', () => {
|
|
316
293
|
});
|
317
294
|
fireEvent.click(fooOption);
|
318
295
|
expect(input).toHaveValue('foo');
|
319
|
-
rerender(
|
320
|
-
renderLabel: "Choose an option"
|
321
|
-
|
322
|
-
}));
|
296
|
+
rerender(/*#__PURE__*/React.createElement(SimpleSelect, {
|
297
|
+
renderLabel: "Choose an option"
|
298
|
+
}, getOptions(updatedOptions)));
|
323
299
|
expect(input).toHaveValue('');
|
324
300
|
});
|
325
301
|
it('should persist selected option if it exists in updated options', () => {
|
@@ -334,10 +310,9 @@ describe('<SimpleSelect />', () => {
|
|
334
310
|
});
|
335
311
|
fireEvent.click(barOption);
|
336
312
|
expect(input).toHaveValue('bar');
|
337
|
-
rerender(
|
338
|
-
renderLabel: "Choose an option"
|
339
|
-
|
340
|
-
}));
|
313
|
+
rerender(/*#__PURE__*/React.createElement(SimpleSelect, {
|
314
|
+
renderLabel: "Choose an option"
|
315
|
+
}, getOptions(updatedOptions)));
|
341
316
|
expect(input).toHaveValue('bar');
|
342
317
|
});
|
343
318
|
});
|
package/es/SimpleSelect/index.js
CHANGED
@@ -27,14 +27,13 @@ var _dec, _dec2, _class, _SimpleSelect;
|
|
27
27
|
* SOFTWARE.
|
28
28
|
*/
|
29
29
|
|
30
|
-
import {
|
30
|
+
import React, { Component, Children } from 'react';
|
31
31
|
import { testable } from '@instructure/ui-testable';
|
32
32
|
import { matchComponentTypes, passthroughProps, callRenderProp, getInteraction, withDeterministicId } from '@instructure/ui-react-utils';
|
33
33
|
import { Select } from '@instructure/ui-select';
|
34
34
|
import { Option } from './Option';
|
35
35
|
import { Group } from './Group';
|
36
36
|
import { allowedProps, propTypes } from './props';
|
37
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
38
37
|
/**
|
39
38
|
---
|
40
39
|
category: components
|
@@ -178,8 +177,8 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
178
177
|
});
|
179
178
|
}
|
180
179
|
hasOptionsChanged(prevChildren, currentChildren) {
|
181
|
-
const getValues = children => Children.map(children, child => {
|
182
|
-
if (/*#__PURE__*/isValidElement(child)) {
|
180
|
+
const getValues = children => React.Children.map(children, child => {
|
181
|
+
if (/*#__PURE__*/React.isValidElement(child)) {
|
183
182
|
return child.props.value;
|
184
183
|
}
|
185
184
|
return null;
|
@@ -261,12 +260,11 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
261
260
|
return children;
|
262
261
|
}
|
263
262
|
renderEmptyOption() {
|
264
|
-
return
|
263
|
+
return /*#__PURE__*/React.createElement(Select.Option, {
|
265
264
|
id: this._emptyOptionId,
|
266
265
|
isHighlighted: false,
|
267
|
-
isSelected: false
|
268
|
-
|
269
|
-
});
|
266
|
+
isSelected: false
|
267
|
+
}, callRenderProp(this.props.renderEmptyOption));
|
270
268
|
}
|
271
269
|
renderOption(option) {
|
272
270
|
const _option$props = option.props,
|
@@ -289,17 +287,16 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
289
287
|
children
|
290
288
|
}) : renderLabel;
|
291
289
|
};
|
292
|
-
return
|
290
|
+
return /*#__PURE__*/React.createElement(Select.Option, Object.assign({
|
293
291
|
id: id,
|
294
292
|
value: value,
|
293
|
+
key: option.key || id,
|
295
294
|
isHighlighted: id === this.state.highlightedOptionId,
|
296
295
|
isSelected: id === this.state.selectedOptionId,
|
297
296
|
isDisabled: option.props.isDisabled,
|
298
297
|
renderBeforeLabel: getRenderLabel(renderBeforeLabel),
|
299
|
-
renderAfterLabel: getRenderLabel(renderAfterLabel)
|
300
|
-
|
301
|
-
children: children
|
302
|
-
}, option.key || id);
|
298
|
+
renderAfterLabel: getRenderLabel(renderAfterLabel)
|
299
|
+
}, passthroughProps(rest)), children);
|
303
300
|
}
|
304
301
|
renderGroup(group) {
|
305
302
|
const _group$props = group.props,
|
@@ -307,11 +304,10 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
307
304
|
renderLabel = _group$props.renderLabel,
|
308
305
|
children = _group$props.children,
|
309
306
|
rest = _objectWithoutProperties(_group$props, _excluded2);
|
310
|
-
return
|
307
|
+
return /*#__PURE__*/React.createElement(Select.Group, Object.assign({
|
311
308
|
renderLabel: renderLabel,
|
312
|
-
|
313
|
-
|
314
|
-
}, group.key || id);
|
309
|
+
key: group.key || id
|
310
|
+
}, passthroughProps(rest)), Children.map(children, child => this.renderOption(child)));
|
315
311
|
}
|
316
312
|
render() {
|
317
313
|
const _this$props = this.props,
|
@@ -344,7 +340,7 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
344
340
|
onHideOptions = _this$props.onHideOptions,
|
345
341
|
children = _this$props.children,
|
346
342
|
rest = _objectWithoutProperties(_this$props, _excluded3);
|
347
|
-
return
|
343
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({
|
348
344
|
renderLabel: renderLabel,
|
349
345
|
inputValue: this.state.inputValue,
|
350
346
|
isShowingOptions: this.state.isShowingOptions,
|
@@ -374,10 +370,8 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
374
370
|
onRequestHideOptions: this.handleHideOptions,
|
375
371
|
onRequestHighlightOption: this.handleHighlightOption,
|
376
372
|
onRequestSelectOption: this.handleSelectOption,
|
377
|
-
isOptionContentAppliedToInput: this.props.isOptionContentAppliedToInput
|
378
|
-
|
379
|
-
children: this.renderChildren()
|
380
|
-
});
|
373
|
+
isOptionContentAppliedToInput: this.props.isOptionContentAppliedToInput
|
374
|
+
}, passthroughProps(rest)), this.renderChildren());
|
381
375
|
}
|
382
376
|
}, _SimpleSelect.displayName = "SimpleSelect", _SimpleSelect.componentId = 'SimpleSelect', _SimpleSelect.Option = Option, _SimpleSelect.Group = Group, _SimpleSelect.allowedProps = allowedProps, _SimpleSelect.propTypes = propTypes, _SimpleSelect.defaultProps = {
|
383
377
|
size: 'medium',
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.default = void 0;
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
7
9
|
var _SimpleSelect = require("../../SimpleSelect");
|
8
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
9
10
|
/*
|
10
11
|
* The MIT License (MIT)
|
11
12
|
*
|
@@ -33,48 +34,48 @@ var _default = exports.default = {
|
|
33
34
|
sectionProp: 'size',
|
34
35
|
maxExamplesPerPage: 50,
|
35
36
|
propValues: {
|
36
|
-
children: [[
|
37
|
+
children: [[/*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
37
38
|
id: "0",
|
38
39
|
value: "0",
|
39
|
-
|
40
|
-
}, "
|
40
|
+
key: "0"
|
41
|
+
}, "Option one"), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
41
42
|
id: "1",
|
42
43
|
value: "1",
|
43
|
-
|
44
|
-
}, "
|
44
|
+
key: "1"
|
45
|
+
}, "Option two"), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
45
46
|
id: "2",
|
46
47
|
value: "2",
|
47
|
-
|
48
|
-
}, "
|
48
|
+
key: "2"
|
49
|
+
}, "Option three"), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
49
50
|
id: "3",
|
50
51
|
value: "3",
|
51
|
-
|
52
|
-
|
53
|
-
}, "
|
52
|
+
key: "3",
|
53
|
+
isDisabled: true
|
54
|
+
}, "Option four")], [/*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
54
55
|
id: "0",
|
55
56
|
value: "0",
|
56
|
-
|
57
|
-
}, "
|
57
|
+
key: "0"
|
58
|
+
}, "Item not in a group"), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Group, {
|
58
59
|
id: "1",
|
59
60
|
renderLabel: "Group one",
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}, "
|
61
|
+
key: "1"
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
63
|
+
id: "2",
|
64
|
+
value: "2",
|
65
|
+
key: "2"
|
66
|
+
}, "Grouped item one")), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Group, {
|
66
67
|
id: "3",
|
67
68
|
renderLabel: "Group two",
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}, "
|
69
|
+
key: "3"
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
71
|
+
id: "4",
|
72
|
+
value: "4",
|
73
|
+
key: "4"
|
74
|
+
}, "Grouped item two")), /*#__PURE__*/_react.default.createElement(_SimpleSelect.SimpleSelect.Option, {
|
74
75
|
id: "5",
|
75
76
|
value: "5",
|
76
|
-
|
77
|
-
}, "
|
77
|
+
key: "5"
|
78
|
+
}, "Item not in a group two")]]
|
78
79
|
},
|
79
80
|
excludeProps: ['isOptionContentAppliedToInput'],
|
80
81
|
getComponentProps: () => {
|