@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
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
5
|
-
var _react = require("
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
6
|
+
var _react2 = require("@testing-library/react");
|
6
7
|
var _vitest = require("vitest");
|
7
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
8
9
|
require("@testing-library/jest-dom");
|
@@ -11,7 +12,6 @@ var _IconCheckSolid2 = require("@instructure/ui-icons/lib/IconCheckSolid.js");
|
|
11
12
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
12
13
|
var _SimpleSelect7 = _interopRequireDefault(require("../__examples__/SimpleSelect.examples"));
|
13
14
|
var _index = _interopRequireDefault(require("../index"));
|
14
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
15
15
|
var _SimpleSelect, _SimpleSelect2, _SimpleSelect3, _SimpleSelect4, _SimpleSelect5, _SimpleSelect6, _IconCheckSolid;
|
16
16
|
/*
|
17
17
|
* The MIT License (MIT)
|
@@ -38,11 +38,11 @@ var _SimpleSelect, _SimpleSelect2, _SimpleSelect3, _SimpleSelect4, _SimpleSelect
|
|
38
38
|
*/
|
39
39
|
// eslint-disable-next-line no-restricted-imports
|
40
40
|
const defaultOptions = ['foo', 'bar', 'baz'];
|
41
|
-
const getOptions = disabled => defaultOptions.map(opt =>
|
41
|
+
const getOptions = disabled => defaultOptions.map(opt => /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
42
42
|
id: opt,
|
43
|
+
key: opt,
|
43
44
|
value: opt,
|
44
|
-
isDisabled: opt === disabled
|
45
|
-
children: opt
|
45
|
+
isDisabled: opt === disabled
|
46
46
|
}, opt));
|
47
47
|
describe('<SimpleSelect />', () => {
|
48
48
|
let consoleErrorMock;
|
@@ -54,52 +54,44 @@ describe('<SimpleSelect />', () => {
|
|
54
54
|
consoleErrorMock.mockRestore();
|
55
55
|
});
|
56
56
|
(0, _vitest.it)('should render an input and a list', async () => {
|
57
|
-
(0,
|
58
|
-
renderLabel: "Choose an option"
|
59
|
-
|
60
|
-
|
61
|
-
const
|
62
|
-
const listInitial = _react.screen.queryByRole('listbox');
|
57
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
58
|
+
renderLabel: "Choose an option"
|
59
|
+
}, getOptions()));
|
60
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
61
|
+
const listInitial = _react2.screen.queryByRole('listbox');
|
63
62
|
expect(listInitial).not.toBeInTheDocument();
|
64
63
|
expect(input).toBeInTheDocument();
|
65
64
|
await _userEvent.default.click(input);
|
66
|
-
await (0,
|
67
|
-
const list =
|
65
|
+
await (0, _react2.waitFor)(() => {
|
66
|
+
const list = _react2.screen.queryByRole('listbox');
|
68
67
|
expect(list).toBeInTheDocument();
|
69
68
|
});
|
70
69
|
});
|
71
70
|
(0, _vitest.it)('should render groups', async () => {
|
72
|
-
(0,
|
73
|
-
renderLabel: "Choose an option"
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
}), (0, _jsxRuntime.jsx)(_index.default.Option, {
|
93
|
-
id: "3",
|
94
|
-
value: "3",
|
95
|
-
children: "ungrouped option two"
|
96
|
-
})]
|
97
|
-
})));
|
98
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
71
|
+
(0, _react2.render)(_SimpleSelect || (_SimpleSelect = /*#__PURE__*/_react.default.createElement(_index.default, {
|
72
|
+
renderLabel: "Choose an option"
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
74
|
+
id: "0",
|
75
|
+
value: "0"
|
76
|
+
}, "ungrouped option one"), /*#__PURE__*/_react.default.createElement(_index.default.Group, {
|
77
|
+
renderLabel: "Group one"
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
79
|
+
id: "1",
|
80
|
+
value: "1"
|
81
|
+
}, "grouped option one")), /*#__PURE__*/_react.default.createElement(_index.default.Group, {
|
82
|
+
renderLabel: "Group two"
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
84
|
+
id: "2",
|
85
|
+
value: "2"
|
86
|
+
}, "grouped option two")), /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
87
|
+
id: "3",
|
88
|
+
value: "3"
|
89
|
+
}, "ungrouped option two"))));
|
90
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
99
91
|
await _userEvent.default.click(input);
|
100
|
-
await (0,
|
101
|
-
const groups =
|
102
|
-
const labelOne =
|
92
|
+
await (0, _react2.waitFor)(() => {
|
93
|
+
const groups = _react2.screen.getAllByRole('group');
|
94
|
+
const labelOne = _react2.screen.getByText('Group one');
|
103
95
|
const labelOneID = labelOne.getAttribute('id');
|
104
96
|
expect(groups.length).toBe(2);
|
105
97
|
expect(groups[0]).toHaveAttribute('aria-labelledby', labelOneID);
|
@@ -107,126 +99,115 @@ describe('<SimpleSelect />', () => {
|
|
107
99
|
});
|
108
100
|
});
|
109
101
|
(0, _vitest.it)('should ignore invalid children', async () => {
|
110
|
-
(0,
|
111
|
-
renderLabel: "Choose an option"
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
children: "invalid"
|
118
|
-
})]
|
119
|
-
})));
|
120
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
102
|
+
(0, _react2.render)(_SimpleSelect2 || (_SimpleSelect2 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
103
|
+
renderLabel: "Choose an option"
|
104
|
+
}, /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
105
|
+
id: "0",
|
106
|
+
value: 0
|
107
|
+
}, "valid"), /*#__PURE__*/_react.default.createElement("div", null, "invalid"))));
|
108
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
121
109
|
await _userEvent.default.click(input);
|
122
|
-
await (0,
|
123
|
-
const invalidChild =
|
110
|
+
await (0, _react2.waitFor)(() => {
|
111
|
+
const invalidChild = _react2.screen.queryByText('invalid');
|
124
112
|
expect(invalidChild).not.toBeInTheDocument();
|
125
113
|
expect(consoleErrorMock).toHaveBeenCalledWith(expect.any(String), expect.any(String), expect.stringContaining('Expected one of Group, Option'), expect.any(String));
|
126
114
|
});
|
127
115
|
});
|
128
116
|
(0, _vitest.it)('should fire onFocus when input gains focus', async () => {
|
129
117
|
const onFocus = _vitest.vi.fn();
|
130
|
-
(0,
|
118
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
131
119
|
renderLabel: "Choose an option",
|
132
|
-
onFocus: onFocus
|
133
|
-
|
134
|
-
|
135
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
120
|
+
onFocus: onFocus
|
121
|
+
}, getOptions()));
|
122
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
136
123
|
input.focus();
|
137
|
-
await (0,
|
124
|
+
await (0, _react2.waitFor)(() => {
|
138
125
|
expect(onFocus).toHaveBeenCalled();
|
139
126
|
});
|
140
127
|
});
|
141
128
|
describe('input', () => {
|
142
129
|
(0, _vitest.it)('should render with a custom id if given', async () => {
|
143
|
-
(0,
|
130
|
+
(0, _react2.render)(_SimpleSelect3 || (_SimpleSelect3 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
144
131
|
renderLabel: "Choose an option",
|
145
132
|
id: "customSelect"
|
146
133
|
})));
|
147
|
-
const input =
|
134
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
148
135
|
expect(input).toHaveAttribute('id', 'customSelect');
|
149
136
|
});
|
150
137
|
(0, _vitest.it)('should always render readonly', async () => {
|
151
|
-
(0,
|
138
|
+
(0, _react2.render)(_SimpleSelect4 || (_SimpleSelect4 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
152
139
|
renderLabel: "Choose an option",
|
153
140
|
interaction: "enabled"
|
154
141
|
})));
|
155
|
-
const input =
|
142
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
156
143
|
expect(input).toHaveAttribute('readonly');
|
157
144
|
expect(input).not.toHaveAttribute('disabled');
|
158
145
|
});
|
159
146
|
(0, _vitest.it)('should render disabled when interaction="disabled"', async () => {
|
160
|
-
(0,
|
147
|
+
(0, _react2.render)(_SimpleSelect5 || (_SimpleSelect5 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
161
148
|
renderLabel: "Choose an option",
|
162
149
|
interaction: "disabled"
|
163
150
|
})));
|
164
|
-
const input =
|
151
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
165
152
|
expect(input).toHaveAttribute('disabled');
|
166
153
|
expect(input).not.toHaveAttribute('readonly');
|
167
154
|
});
|
168
155
|
(0, _vitest.it)('should render required when isRequired={true}', async () => {
|
169
|
-
(0,
|
156
|
+
(0, _react2.render)(_SimpleSelect6 || (_SimpleSelect6 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
170
157
|
renderLabel: "Choose an option",
|
171
158
|
isRequired: true
|
172
159
|
})));
|
173
|
-
const input =
|
160
|
+
const input = _react2.screen.getByLabelText('Choose an option *');
|
174
161
|
expect(input).toHaveAttribute('required');
|
175
162
|
});
|
176
163
|
(0, _vitest.it)('should allow assistive text', async () => {
|
177
|
-
(0,
|
164
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
178
165
|
renderLabel: "Choose an option",
|
179
|
-
assistiveText: "hello world"
|
180
|
-
|
181
|
-
|
182
|
-
const
|
183
|
-
const assistiveText = _react.screen.getByText('hello world');
|
166
|
+
assistiveText: "hello world"
|
167
|
+
}, getOptions()));
|
168
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
169
|
+
const assistiveText = _react2.screen.getByText('hello world');
|
184
170
|
const assistiveTextID = assistiveText.getAttribute('id');
|
185
171
|
expect(input).toHaveAttribute('aria-describedby', assistiveTextID);
|
186
172
|
});
|
187
173
|
(0, _vitest.it)('should allow custom props to pass through', async () => {
|
188
|
-
(0,
|
174
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
189
175
|
renderLabel: "Choose an option",
|
190
|
-
"data-custom-attr": "true"
|
191
|
-
|
192
|
-
|
193
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
176
|
+
"data-custom-attr": "true"
|
177
|
+
}, getOptions()));
|
178
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
194
179
|
expect(input).toHaveAttribute('data-custom-attr', 'true');
|
195
180
|
});
|
196
181
|
(0, _vitest.it)('should provide a ref to the input element', async () => {
|
197
182
|
const inputRef = _vitest.vi.fn();
|
198
|
-
(0,
|
183
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
199
184
|
renderLabel: "Choose an option",
|
200
|
-
inputRef: inputRef
|
201
|
-
|
202
|
-
|
203
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
185
|
+
inputRef: inputRef
|
186
|
+
}, getOptions()));
|
187
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
204
188
|
expect(inputRef).toHaveBeenCalledWith(input);
|
205
189
|
});
|
206
190
|
});
|
207
191
|
(0, _vitest.it)('should render icons before option and call renderBeforeLabel callback with necessary props', async () => {
|
208
|
-
const renderBeforeLabel = _vitest.vi.fn(() => _IconCheckSolid || (_IconCheckSolid =
|
192
|
+
const renderBeforeLabel = _vitest.vi.fn(() => _IconCheckSolid || (_IconCheckSolid = /*#__PURE__*/_react.default.createElement(_IconCheckSolid2.IconCheckSolid, {
|
209
193
|
"data-testid": "option-icon"
|
210
194
|
})));
|
211
|
-
(0,
|
212
|
-
renderLabel: "Choose an option"
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
})]
|
225
|
-
}));
|
226
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
195
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
196
|
+
renderLabel: "Choose an option"
|
197
|
+
}, /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
198
|
+
id: "option-1",
|
199
|
+
value: "1",
|
200
|
+
isDisabled: true,
|
201
|
+
renderBeforeLabel: renderBeforeLabel
|
202
|
+
}, "option one"), /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
203
|
+
id: "option-2",
|
204
|
+
value: "2",
|
205
|
+
renderBeforeLabel: renderBeforeLabel
|
206
|
+
}, "option two")));
|
207
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
227
208
|
await _userEvent.default.click(input);
|
228
|
-
await (0,
|
229
|
-
const optionIcons =
|
209
|
+
await (0, _react2.waitFor)(() => {
|
210
|
+
const optionIcons = _react2.screen.getAllByTestId('option-icon');
|
230
211
|
expect(optionIcons.length).toBe(2);
|
231
212
|
expect(renderBeforeLabel).toHaveBeenCalledTimes(2);
|
232
213
|
const _ref = renderBeforeLabel.mock.calls,
|
@@ -253,29 +234,27 @@ describe('<SimpleSelect />', () => {
|
|
253
234
|
});
|
254
235
|
describe('list', () => {
|
255
236
|
(0, _vitest.it)('should set aria-disabled on options when isDisabled={true}', async () => {
|
256
|
-
(0,
|
257
|
-
renderLabel: "Choose an option"
|
258
|
-
|
259
|
-
|
260
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
237
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
238
|
+
renderLabel: "Choose an option"
|
239
|
+
}, getOptions(defaultOptions[2])));
|
240
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
261
241
|
await _userEvent.default.click(input);
|
262
|
-
await (0,
|
263
|
-
const options =
|
242
|
+
await (0, _react2.waitFor)(() => {
|
243
|
+
const options = _react2.screen.getAllByRole('option');
|
264
244
|
expect(options[0]).not.toHaveAttribute('aria-disabled');
|
265
245
|
expect(options[2]).toHaveAttribute('aria-disabled', 'true');
|
266
246
|
});
|
267
247
|
});
|
268
248
|
(0, _vitest.it)('should provide a ref to the list element', async () => {
|
269
249
|
const listRef = _vitest.vi.fn();
|
270
|
-
(0,
|
250
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
271
251
|
renderLabel: "Choose an option",
|
272
|
-
listRef: listRef
|
273
|
-
|
274
|
-
|
275
|
-
const input = _react.screen.getByLabelText('Choose an option');
|
252
|
+
listRef: listRef
|
253
|
+
}, getOptions()));
|
254
|
+
const input = _react2.screen.getByLabelText('Choose an option');
|
276
255
|
await _userEvent.default.click(input);
|
277
|
-
await (0,
|
278
|
-
const listbox =
|
256
|
+
await (0, _react2.waitFor)(() => {
|
257
|
+
const listbox = _react2.screen.getByRole('listbox');
|
279
258
|
expect(listRef).toHaveBeenCalledWith(listbox);
|
280
259
|
});
|
281
260
|
});
|
@@ -285,7 +264,7 @@ describe('<SimpleSelect />', () => {
|
|
285
264
|
_vitest.it.each(generatedComponents)('should be accessible with example: $description', async ({
|
286
265
|
content
|
287
266
|
}) => {
|
288
|
-
const _render = (0,
|
267
|
+
const _render = (0, _react2.render)(content),
|
289
268
|
container = _render.container;
|
290
269
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
291
270
|
expect(axeCheck).toBe(true);
|
@@ -294,51 +273,48 @@ describe('<SimpleSelect />', () => {
|
|
294
273
|
describe('children', () => {
|
295
274
|
const initialOptions = ['foo', 'bar'];
|
296
275
|
const updatedOptions = ['bar', 'baz'];
|
297
|
-
const getOptions = options => options.map(opt =>
|
276
|
+
const getOptions = options => options.map(opt => /*#__PURE__*/_react.default.createElement(_index.default.Option, {
|
298
277
|
id: opt,
|
299
|
-
|
300
|
-
|
278
|
+
key: opt,
|
279
|
+
value: opt
|
301
280
|
}, opt));
|
302
281
|
const renderSimpleSelect = options => {
|
303
|
-
return (0,
|
304
|
-
renderLabel: "Choose an option"
|
305
|
-
|
306
|
-
}));
|
282
|
+
return (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
283
|
+
renderLabel: "Choose an option"
|
284
|
+
}, getOptions(options)));
|
307
285
|
};
|
308
286
|
(0, _vitest.it)('should clear selection if selected option does not exist in updated options', () => {
|
309
287
|
const _renderSimpleSelect = renderSimpleSelect(initialOptions),
|
310
288
|
rerender = _renderSimpleSelect.rerender;
|
311
|
-
const input =
|
289
|
+
const input = _react2.screen.getByRole('combobox', {
|
312
290
|
name: 'Choose an option'
|
313
291
|
});
|
314
|
-
|
315
|
-
const fooOption =
|
292
|
+
_react2.fireEvent.click(input);
|
293
|
+
const fooOption = _react2.screen.getByRole('option', {
|
316
294
|
name: 'foo'
|
317
295
|
});
|
318
|
-
|
296
|
+
_react2.fireEvent.click(fooOption);
|
319
297
|
expect(input).toHaveValue('foo');
|
320
|
-
rerender(
|
321
|
-
renderLabel: "Choose an option"
|
322
|
-
|
323
|
-
}));
|
298
|
+
rerender(/*#__PURE__*/_react.default.createElement(_index.default, {
|
299
|
+
renderLabel: "Choose an option"
|
300
|
+
}, getOptions(updatedOptions)));
|
324
301
|
expect(input).toHaveValue('');
|
325
302
|
});
|
326
303
|
(0, _vitest.it)('should persist selected option if it exists in updated options', () => {
|
327
304
|
const _renderSimpleSelect2 = renderSimpleSelect(initialOptions),
|
328
305
|
rerender = _renderSimpleSelect2.rerender;
|
329
|
-
const input =
|
306
|
+
const input = _react2.screen.getByRole('combobox', {
|
330
307
|
name: 'Choose an option'
|
331
308
|
});
|
332
|
-
|
333
|
-
const barOption =
|
309
|
+
_react2.fireEvent.click(input);
|
310
|
+
const barOption = _react2.screen.getByRole('option', {
|
334
311
|
name: 'bar'
|
335
312
|
});
|
336
|
-
|
313
|
+
_react2.fireEvent.click(barOption);
|
337
314
|
expect(input).toHaveValue('bar');
|
338
|
-
rerender(
|
339
|
-
renderLabel: "Choose an option"
|
340
|
-
|
341
|
-
}));
|
315
|
+
rerender(/*#__PURE__*/_react.default.createElement(_index.default, {
|
316
|
+
renderLabel: "Choose an option"
|
317
|
+
}, getOptions(updatedOptions)));
|
342
318
|
expect(input).toHaveValue('bar');
|
343
319
|
});
|
344
320
|
});
|
@@ -1,12 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.default = exports.SimpleSelect = void 0;
|
8
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
9
|
-
var _react = require("react");
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
10
11
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
11
12
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
12
13
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
@@ -17,7 +18,6 @@ var _Select = require("@instructure/ui-select/lib/Select");
|
|
17
18
|
var _Option = require("./Option");
|
18
19
|
var _Group = require("./Group");
|
19
20
|
var _props = require("./props");
|
20
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
21
21
|
const _excluded = ["id", "value", "children", "renderBeforeLabel", "renderAfterLabel"],
|
22
22
|
_excluded2 = ["id", "renderLabel", "children"],
|
23
23
|
_excluded3 = ["renderLabel", "value", "defaultValue", "id", "size", "assistiveText", "placeholder", "interaction", "isRequired", "isInline", "width", "optionsMaxWidth", "optionsMaxHeight", "visibleOptionsCount", "messages", "placement", "constrain", "mountNode", "inputRef", "listRef", "renderEmptyOption", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onShowOptions", "onHideOptions", "children"];
|
@@ -188,8 +188,8 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
188
188
|
});
|
189
189
|
}
|
190
190
|
hasOptionsChanged(prevChildren, currentChildren) {
|
191
|
-
const getValues = children => _react.Children.map(children, child => {
|
192
|
-
if (/*#__PURE__*/
|
191
|
+
const getValues = children => _react.default.Children.map(children, child => {
|
192
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
193
193
|
return child.props.value;
|
194
194
|
}
|
195
195
|
return null;
|
@@ -271,12 +271,11 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
271
271
|
return children;
|
272
272
|
}
|
273
273
|
renderEmptyOption() {
|
274
|
-
return
|
274
|
+
return /*#__PURE__*/_react.default.createElement(_Select.Select.Option, {
|
275
275
|
id: this._emptyOptionId,
|
276
276
|
isHighlighted: false,
|
277
|
-
isSelected: false
|
278
|
-
|
279
|
-
});
|
277
|
+
isSelected: false
|
278
|
+
}, (0, _callRenderProp.callRenderProp)(this.props.renderEmptyOption));
|
280
279
|
}
|
281
280
|
renderOption(option) {
|
282
281
|
const _option$props = option.props,
|
@@ -299,17 +298,16 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
299
298
|
children
|
300
299
|
}) : renderLabel;
|
301
300
|
};
|
302
|
-
return
|
301
|
+
return /*#__PURE__*/_react.default.createElement(_Select.Select.Option, Object.assign({
|
303
302
|
id: id,
|
304
303
|
value: value,
|
304
|
+
key: option.key || id,
|
305
305
|
isHighlighted: id === this.state.highlightedOptionId,
|
306
306
|
isSelected: id === this.state.selectedOptionId,
|
307
307
|
isDisabled: option.props.isDisabled,
|
308
308
|
renderBeforeLabel: getRenderLabel(renderBeforeLabel),
|
309
|
-
renderAfterLabel: getRenderLabel(renderAfterLabel)
|
310
|
-
|
311
|
-
children: children
|
312
|
-
}, option.key || id);
|
309
|
+
renderAfterLabel: getRenderLabel(renderAfterLabel)
|
310
|
+
}, (0, _passthroughProps.passthroughProps)(rest)), children);
|
313
311
|
}
|
314
312
|
renderGroup(group) {
|
315
313
|
const _group$props = group.props,
|
@@ -317,11 +315,10 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
317
315
|
renderLabel = _group$props.renderLabel,
|
318
316
|
children = _group$props.children,
|
319
317
|
rest = (0, _objectWithoutProperties2.default)(_group$props, _excluded2);
|
320
|
-
return
|
318
|
+
return /*#__PURE__*/_react.default.createElement(_Select.Select.Group, Object.assign({
|
321
319
|
renderLabel: renderLabel,
|
322
|
-
|
323
|
-
|
324
|
-
}, group.key || id);
|
320
|
+
key: group.key || id
|
321
|
+
}, (0, _passthroughProps.passthroughProps)(rest)), _react.Children.map(children, child => this.renderOption(child)));
|
325
322
|
}
|
326
323
|
render() {
|
327
324
|
const _this$props = this.props,
|
@@ -354,7 +351,7 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
354
351
|
onHideOptions = _this$props.onHideOptions,
|
355
352
|
children = _this$props.children,
|
356
353
|
rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded3);
|
357
|
-
return
|
354
|
+
return /*#__PURE__*/_react.default.createElement(_Select.Select, Object.assign({
|
358
355
|
renderLabel: renderLabel,
|
359
356
|
inputValue: this.state.inputValue,
|
360
357
|
isShowingOptions: this.state.isShowingOptions,
|
@@ -384,10 +381,8 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
384
381
|
onRequestHideOptions: this.handleHideOptions,
|
385
382
|
onRequestHighlightOption: this.handleHighlightOption,
|
386
383
|
onRequestSelectOption: this.handleSelectOption,
|
387
|
-
isOptionContentAppliedToInput: this.props.isOptionContentAppliedToInput
|
388
|
-
|
389
|
-
children: this.renderChildren()
|
390
|
-
});
|
384
|
+
isOptionContentAppliedToInput: this.props.isOptionContentAppliedToInput
|
385
|
+
}, (0, _passthroughProps.passthroughProps)(rest)), this.renderChildren());
|
391
386
|
}
|
392
387
|
}, _SimpleSelect.displayName = "SimpleSelect", _SimpleSelect.componentId = 'SimpleSelect', _SimpleSelect.Option = _Option.Option, _SimpleSelect.Group = _Group.Group, _SimpleSelect.allowedProps = _props.allowedProps, _SimpleSelect.propTypes = _props.propTypes, _SimpleSelect.defaultProps = {
|
393
388
|
size: 'medium',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-simple-select",
|
3
|
-
"version": "10.16.1-
|
3
|
+
"version": "10.16.1-snapshot-0",
|
4
4
|
"description": "A component for standard select element behavior.",
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
6
6
|
"module": "./es/index.js",
|
@@ -24,23 +24,23 @@
|
|
24
24
|
"license": "MIT",
|
25
25
|
"dependencies": {
|
26
26
|
"@babel/runtime": "^7.26.0",
|
27
|
-
"@instructure/console": "10.16.1-
|
28
|
-
"@instructure/shared-types": "10.16.1-
|
29
|
-
"@instructure/ui-form-field": "10.16.1-
|
30
|
-
"@instructure/ui-position": "10.16.1-
|
31
|
-
"@instructure/ui-prop-types": "10.16.1-
|
32
|
-
"@instructure/ui-react-utils": "10.16.1-
|
33
|
-
"@instructure/ui-select": "10.16.1-
|
34
|
-
"@instructure/ui-testable": "10.16.1-
|
27
|
+
"@instructure/console": "10.16.1-snapshot-0",
|
28
|
+
"@instructure/shared-types": "10.16.1-snapshot-0",
|
29
|
+
"@instructure/ui-form-field": "10.16.1-snapshot-0",
|
30
|
+
"@instructure/ui-position": "10.16.1-snapshot-0",
|
31
|
+
"@instructure/ui-prop-types": "10.16.1-snapshot-0",
|
32
|
+
"@instructure/ui-react-utils": "10.16.1-snapshot-0",
|
33
|
+
"@instructure/ui-select": "10.16.1-snapshot-0",
|
34
|
+
"@instructure/ui-testable": "10.16.1-snapshot-0",
|
35
35
|
"prop-types": "^15.8.1"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
-
"@instructure/ui-axe-check": "10.16.1-
|
39
|
-
"@instructure/ui-babel-preset": "10.16.1-
|
40
|
-
"@instructure/ui-color-utils": "10.16.1-
|
41
|
-
"@instructure/ui-icons": "10.16.1-
|
42
|
-
"@instructure/ui-test-utils": "10.16.1-
|
43
|
-
"@instructure/ui-utils": "10.16.1-
|
38
|
+
"@instructure/ui-axe-check": "10.16.1-snapshot-0",
|
39
|
+
"@instructure/ui-babel-preset": "10.16.1-snapshot-0",
|
40
|
+
"@instructure/ui-color-utils": "10.16.1-snapshot-0",
|
41
|
+
"@instructure/ui-icons": "10.16.1-snapshot-0",
|
42
|
+
"@instructure/ui-test-utils": "10.16.1-snapshot-0",
|
43
|
+
"@instructure/ui-utils": "10.16.1-snapshot-0",
|
44
44
|
"@testing-library/jest-dom": "^6.6.3",
|
45
45
|
"@testing-library/react": "^16.0.1",
|
46
46
|
"@testing-library/user-event": "^14.5.2",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
22
|
* SOFTWARE.
|
23
23
|
*/
|
24
|
-
|
24
|
+
import React from 'react'
|
25
25
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
26
26
|
import { vi, MockInstance, it } from 'vitest'
|
27
27
|
import userEvent from '@testing-library/user-event'
|
@@ -22,7 +22,7 @@
|
|
22
22
|
* SOFTWARE.
|
23
23
|
*/
|
24
24
|
|
25
|
-
import
|
25
|
+
import React, { Component, Children } from 'react'
|
26
26
|
|
27
27
|
import { testable } from '@instructure/ui-testable'
|
28
28
|
import {
|
@@ -48,8 +48,8 @@ import type { SimpleSelectGroupProps } from './Group/props'
|
|
48
48
|
import type { SimpleSelectProps } from './props'
|
49
49
|
import { allowedProps, propTypes, SimpleSelectState } from './props'
|
50
50
|
|
51
|
-
type OptionChild = ComponentElement<SimpleSelectOptionProps, Option>
|
52
|
-
type GroupChild = ComponentElement<SimpleSelectGroupProps, Group>
|
51
|
+
type OptionChild = React.ComponentElement<SimpleSelectOptionProps, Option>
|
52
|
+
type GroupChild = React.ComponentElement<SimpleSelectGroupProps, Group>
|
53
53
|
|
54
54
|
type GetOption = <F extends keyof SimpleSelectOptionProps>(
|
55
55
|
field: F,
|
@@ -136,8 +136,8 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
|
|
136
136
|
currentChildren: SimpleSelectProps['children']
|
137
137
|
) {
|
138
138
|
const getValues = (children: SimpleSelectProps['children']) =>
|
139
|
-
Children.map(children, (child) => {
|
140
|
-
if (isValidElement(child)) {
|
139
|
+
React.Children.map(children, (child) => {
|
140
|
+
if (React.isValidElement(child)) {
|
141
141
|
return child.props.value
|
142
142
|
}
|
143
143
|
return null
|