@instructure/ui-simple-select 11.7.2-snapshot-48 → 11.7.2-snapshot-49

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/es/SimpleSelect/v2/Group/index.js +46 -0
  3. package/es/SimpleSelect/v2/Group/props.js +26 -0
  4. package/es/SimpleSelect/v2/Option/index.js +48 -0
  5. package/es/SimpleSelect/v2/Option/props.js +26 -0
  6. package/es/SimpleSelect/v2/index.js +444 -0
  7. package/es/SimpleSelect/v2/props.js +26 -0
  8. package/es/exports/b.js +26 -0
  9. package/lib/SimpleSelect/v2/Group/index.js +52 -0
  10. package/lib/SimpleSelect/v2/Group/props.js +31 -0
  11. package/lib/SimpleSelect/v2/Option/index.js +54 -0
  12. package/lib/SimpleSelect/v2/Option/props.js +31 -0
  13. package/lib/SimpleSelect/v2/index.js +454 -0
  14. package/lib/SimpleSelect/v2/props.js +31 -0
  15. package/lib/exports/b.js +26 -0
  16. package/package.json +21 -21
  17. package/src/SimpleSelect/v2/Group/index.tsx +51 -0
  18. package/src/SimpleSelect/v2/Group/props.ts +49 -0
  19. package/src/SimpleSelect/v2/Option/index.tsx +52 -0
  20. package/src/SimpleSelect/v2/Option/props.ts +83 -0
  21. package/src/SimpleSelect/v2/README.md +157 -0
  22. package/src/SimpleSelect/v2/index.tsx +559 -0
  23. package/src/SimpleSelect/v2/props.ts +300 -0
  24. package/src/exports/b.ts +31 -0
  25. package/tsconfig.build.tsbuildinfo +1 -1
  26. package/types/SimpleSelect/v2/Group/index.d.ts +20 -0
  27. package/types/SimpleSelect/v2/Group/index.d.ts.map +1 -0
  28. package/types/SimpleSelect/v2/Group/props.d.ts +19 -0
  29. package/types/SimpleSelect/v2/Group/props.d.ts.map +1 -0
  30. package/types/SimpleSelect/v2/Option/index.d.ts +26 -0
  31. package/types/SimpleSelect/v2/Option/index.d.ts.map +1 -0
  32. package/types/SimpleSelect/v2/Option/props.d.ts +45 -0
  33. package/types/SimpleSelect/v2/Option/props.d.ts.map +1 -0
  34. package/types/SimpleSelect/v2/index.d.ts +90 -0
  35. package/types/SimpleSelect/v2/index.d.ts.map +1 -0
  36. package/types/SimpleSelect/v2/props.d.ts +180 -0
  37. package/types/SimpleSelect/v2/props.d.ts.map +1 -0
  38. package/types/exports/b.d.ts +7 -0
  39. package/types/exports/b.d.ts.map +1 -0
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Group = void 0;
7
+ var _react = require("react");
8
+ var _props = require("./props");
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+
33
+ /**
34
+ ---
35
+ parent: SimpleSelect
36
+ id: SimpleSelect.Group
37
+ ---
38
+ **/
39
+ class Group extends _react.Component {
40
+ /* istanbul ignore next */
41
+ render() {
42
+ // this component is only used for prop validation. Select.Group children
43
+ // are parsed in Select and rendered as Options components
44
+ return null;
45
+ }
46
+ }
47
+ exports.Group = Group;
48
+ Group.displayName = "Group";
49
+ Group.componentId = 'SimpleSelect.Group';
50
+ Group.allowedProps = _props.allowedProps;
51
+ Group.defaultProps = {};
52
+ var _default = exports.default = Group;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['renderLabel', 'children'];
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Option = void 0;
7
+ var _react = require("react");
8
+ var _props = require("./props");
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+
33
+ /**
34
+ ---
35
+ parent: SimpleSelect
36
+ id: SimpleSelect.Option
37
+ ---
38
+ **/
39
+ class Option extends _react.Component {
40
+ /* istanbul ignore next */
41
+ render() {
42
+ // this component is only used for prop validation. SimpleSelect.Option children
43
+ // are parsed in Select and rendered as Options.Item components
44
+ return null;
45
+ }
46
+ }
47
+ exports.Option = Option;
48
+ Option.displayName = "Option";
49
+ Option.componentId = 'SimpleSelect.Option';
50
+ Option.allowedProps = _props.allowedProps;
51
+ Option.defaultProps = {
52
+ isDisabled: false
53
+ };
54
+ var _default = exports.default = Option;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['id', 'value', 'isDisabled', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
@@ -0,0 +1,454 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = exports.SimpleSelect = void 0;
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = require("react");
11
+ var utils = _interopRequireWildcard(require("@instructure/ui-utils"));
12
+ var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
13
+ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
14
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
15
+ var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
16
+ var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
17
+ var _latest = require("@instructure/ui-select/latest");
18
+ var _Option = require("./Option");
19
+ var _Group = require("./Group");
20
+ var _props = require("./props");
21
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
+ const _excluded = ["id", "value", "children", "renderBeforeLabel", "renderAfterLabel"],
23
+ _excluded2 = ["id", "renderLabel", "children"],
24
+ _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", "layout"];
25
+ var _dec, _class, _SimpleSelect;
26
+ /*
27
+ * The MIT License (MIT)
28
+ *
29
+ * Copyright (c) 2015 - present Instructure, Inc.
30
+ *
31
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ * of this software and associated documentation files (the "Software"), to deal
33
+ * in the Software without restriction, including without limitation the rights
34
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ * copies of the Software, and to permit persons to whom the Software is
36
+ * furnished to do so, subject to the following conditions:
37
+ *
38
+ * The above copyright notice and this permission notice shall be included in all
39
+ * copies or substantial portions of the Software.
40
+ *
41
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
+ * SOFTWARE.
48
+ */
49
+ /**
50
+ ---
51
+ category: components
52
+ tags: form, field, dropdown
53
+ ---
54
+ **/
55
+ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec(_class = (_SimpleSelect = class SimpleSelect extends _react.Component {
56
+ constructor(props) {
57
+ super(props);
58
+ this.ref = null;
59
+ this._emptyOptionId = void 0;
60
+ this.getOption = (field, value) => {
61
+ const children = _react.Children.toArray(this.props.children);
62
+ let match;
63
+ for (let i = 0; i < children.length; ++i) {
64
+ const child = children[i];
65
+ if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
66
+ if (child.props[field] === value) {
67
+ match = child;
68
+ }
69
+ } else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
70
+ const groupChildren = _react.Children.toArray(child.props.children);
71
+ for (let j = 0; j < groupChildren.length; ++j) {
72
+ const groupChild = groupChildren[j];
73
+ if (groupChild.props[field] === value) {
74
+ match = groupChild;
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ if (match) break;
80
+ }
81
+ return match;
82
+ };
83
+ this.handleRef = node => {
84
+ this.ref = node;
85
+ };
86
+ this.handleBlur = event => {
87
+ this.setState({
88
+ highlightedOptionId: void 0
89
+ });
90
+ if (typeof this.props.onBlur === 'function') {
91
+ this.props.onBlur(event);
92
+ }
93
+ };
94
+ this.handleShowOptions = event => {
95
+ this.setState({
96
+ isShowingOptions: true
97
+ });
98
+ if (typeof this.props.onShowOptions === 'function') {
99
+ this.props.onShowOptions(event);
100
+ }
101
+ if (event.type.startsWith('key')) {
102
+ const keyboardEvent = event;
103
+ const children = _react.Children.toArray(this.props.children);
104
+ if (!this.state.inputValue && children.length > 0) {
105
+ const position = keyboardEvent.key === 'ArrowDown' ? 'first' : keyboardEvent.key === 'ArrowUp' ? 'last' : void 0;
106
+ if (position) {
107
+ var _this$getOptionByPosi;
108
+ const optionId = (_this$getOptionByPosi = this.getOptionByPosition(position)) === null || _this$getOptionByPosi === void 0 ? void 0 : _this$getOptionByPosi.props.id;
109
+ optionId && this.setState({
110
+ highlightedOptionId: optionId
111
+ });
112
+ }
113
+ }
114
+ }
115
+ };
116
+ this.handleHideOptions = event => {
117
+ this.setState(state => {
118
+ const option = this.getOption('id', state.selectedOptionId);
119
+ return {
120
+ isShowingOptions: false,
121
+ highlightedOptionId: void 0,
122
+ inputValue: option ? option.props.children : ''
123
+ };
124
+ });
125
+ if (typeof this.props.onHideOptions === 'function') {
126
+ this.props.onHideOptions(event);
127
+ }
128
+ };
129
+ this.handleHighlightOption = (_event, {
130
+ id
131
+ }) => {
132
+ if (id === this._emptyOptionId) return;
133
+ this.setState({
134
+ highlightedOptionId: id,
135
+ inputValue: this.state.inputValue
136
+ });
137
+ };
138
+ this.handleSelectOption = (event, {
139
+ id
140
+ }) => {
141
+ if (id === this._emptyOptionId) {
142
+ // selected option is the empty option
143
+ this.setState({
144
+ isShowingOptions: false
145
+ });
146
+ return;
147
+ }
148
+ const option = this.getOption('id', id);
149
+ const value = option && option.props.value;
150
+
151
+ // Focus needs to be reapplied to input
152
+ // after selecting an item to make sure VoiceOver behaves correctly on iOS
153
+ if (utils.isAndroidOrIOS()) {
154
+ this.blur();
155
+ this.focus();
156
+ }
157
+ if (this.isControlled) {
158
+ this.setState({
159
+ isShowingOptions: false
160
+ });
161
+ } else {
162
+ this.setState(state => ({
163
+ isShowingOptions: false,
164
+ selectedOptionId: id,
165
+ inputValue: option ? option.props.children : state.inputValue
166
+ }));
167
+ }
168
+ // fire onChange if selected option changed
169
+ if (option && typeof this.props.onChange === 'function') {
170
+ this.props.onChange(event, {
171
+ value,
172
+ id
173
+ });
174
+ }
175
+ // hide options list whenever selection is made
176
+ if (typeof this.props.onHideOptions === 'function') {
177
+ this.props.onHideOptions(event);
178
+ }
179
+ };
180
+ const _option = this.getInitialOption(props);
181
+ this.state = {
182
+ inputValue: _option ? _option.props.children : '',
183
+ isShowingOptions: false,
184
+ highlightedOptionId: void 0,
185
+ selectedOptionId: _option ? _option.props.id : void 0
186
+ };
187
+ this._emptyOptionId = props.deterministicId('Select-EmptyOption');
188
+ }
189
+ get _select() {
190
+ return this.ref;
191
+ }
192
+ focus() {
193
+ this.ref && this.ref.focus();
194
+ }
195
+ blur() {
196
+ this.ref && this.ref.blur();
197
+ }
198
+ get focused() {
199
+ return this.ref ? this.ref.focused : false;
200
+ }
201
+ get id() {
202
+ return this.ref ? this.ref.id : void 0;
203
+ }
204
+ get isControlled() {
205
+ return typeof this.props.value !== 'undefined';
206
+ }
207
+ get interaction() {
208
+ return (0, _getInteraction.getInteraction)({
209
+ props: this.props
210
+ });
211
+ }
212
+ hasOptionsChanged(prevChildren, currentChildren) {
213
+ const getValues = children => _react.Children.map(children, child => {
214
+ if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
215
+ return child.props.value;
216
+ }
217
+ return null;
218
+ });
219
+ const prevValues = getValues(prevChildren);
220
+ const currentValues = getValues(currentChildren);
221
+ return JSON.stringify(prevValues) !== JSON.stringify(currentValues);
222
+ }
223
+ componentDidUpdate(prevProps) {
224
+ if (this.hasOptionsChanged(prevProps.children, this.props.children)) {
225
+ // Compare current input value to children's child prop, this is put into
226
+ // state.inputValue
227
+ const option = this.getOption('children', this.state.inputValue);
228
+ this.setState({
229
+ inputValue: option ? option.props.children : void 0,
230
+ selectedOptionId: option ? option.props.id : ''
231
+ });
232
+ }
233
+ if (this.props.value !== prevProps.value) {
234
+ // if value has changed externally try to find an option with the same value
235
+ // and select it
236
+ let option = this.getOption('value', this.props.value);
237
+ if (typeof this.props.value === 'undefined') {
238
+ // preserve current value when changing from controlled to uncontrolled
239
+ option = this.getOption('value', prevProps.value);
240
+ }
241
+ this.setState({
242
+ inputValue: option ? option.props.children : '',
243
+ selectedOptionId: option ? option.props.id : ''
244
+ });
245
+ }
246
+ }
247
+ getInitialOption(props) {
248
+ const value = props.value,
249
+ defaultValue = props.defaultValue;
250
+ const initialValue = value || defaultValue;
251
+ if (typeof initialValue === 'string' || typeof initialValue === 'number') {
252
+ // get option based on value or defaultValue, if provided
253
+ return this.getOption('value', initialValue);
254
+ }
255
+ // otherwise get the first option
256
+ return this.getFirstOption();
257
+ }
258
+ getOptionLabelById(id) {
259
+ const option = this.getOption('id', id);
260
+ return option ? option.props.children : '';
261
+ }
262
+ getFirstOption() {
263
+ const children = _react.Children.toArray(this.props.children);
264
+ let match;
265
+ for (let i = 0; i < children.length; i++) {
266
+ const child = children[i];
267
+ if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
268
+ match = child;
269
+ } else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
270
+ // first child is a group, not an option, find first child in group
271
+ match = _react.Children.toArray(child.props.children)[0];
272
+ }
273
+ if (match) {
274
+ break;
275
+ }
276
+ }
277
+ return match;
278
+ }
279
+ getOptionByPosition(position) {
280
+ const children = _react.Children.toArray(this.props.children);
281
+
282
+ // Determine where to start looking based on position
283
+ const index = position === 'first' ? 0 : children.length - 1;
284
+
285
+ // Check if child is an option or group
286
+ const child = children[index];
287
+ if (!child) return void 0;
288
+
289
+ // If it's a regular option, return it
290
+ if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
291
+ return child;
292
+ }
293
+
294
+ // If it's a group, get its options
295
+ if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
296
+ const groupOptions = _react.Children.toArray(child.props.children);
297
+ const groupIndex = position === 'first' ? 0 : groupOptions.length - 1;
298
+ return groupOptions[groupIndex];
299
+ }
300
+ return void 0;
301
+ }
302
+ renderChildren() {
303
+ let children = _react.Children.toArray(this.props.children);
304
+ children = _react.Children.map(children, child => {
305
+ if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
306
+ return this.renderOption(child);
307
+ } else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
308
+ return this.renderGroup(child);
309
+ }
310
+ return null;
311
+ }).filter(child => !!child);
312
+ if (children.length === 0) {
313
+ // no valid children, render empty option
314
+ return this.renderEmptyOption();
315
+ }
316
+ return children;
317
+ }
318
+ renderEmptyOption() {
319
+ return (0, _jsxRuntime.jsx)(_latest.Select.Option, {
320
+ id: this._emptyOptionId,
321
+ isHighlighted: false,
322
+ isSelected: false,
323
+ children: (0, _callRenderProp.callRenderProp)(this.props.renderEmptyOption)
324
+ });
325
+ }
326
+ renderOption(option) {
327
+ var _option$props$isDisab;
328
+ const _option$props = option.props,
329
+ id = _option$props.id,
330
+ value = _option$props.value,
331
+ children = _option$props.children,
332
+ renderBeforeLabel = _option$props.renderBeforeLabel,
333
+ renderAfterLabel = _option$props.renderAfterLabel,
334
+ rest = (0, _objectWithoutProperties2.default)(_option$props, _excluded);
335
+ const isDisabled = (_option$props$isDisab = option.props.isDisabled) !== null && _option$props$isDisab !== void 0 ? _option$props$isDisab : false; // after the react 19 upgrade `isDisabled` is undefined instead of defaulting to false if not specified (but only in vitest env for some reason)
336
+ const isSelected = id === this.state.selectedOptionId;
337
+ const isHighlighted = id === this.state.highlightedOptionId;
338
+ const getRenderLabel = renderLabel => {
339
+ var _renderLabel$prototyp;
340
+ if (typeof renderLabel === 'function' && !(renderLabel !== null && renderLabel !== void 0 && (_renderLabel$prototyp = renderLabel.prototype) !== null && _renderLabel$prototyp !== void 0 && _renderLabel$prototyp.isReactComponent)) {
341
+ return renderLabel.bind(null, {
342
+ id,
343
+ isDisabled,
344
+ isSelected,
345
+ isHighlighted,
346
+ children
347
+ });
348
+ }
349
+ return renderLabel;
350
+ };
351
+ return (0, _jsxRuntime.jsx)(_latest.Select.Option, {
352
+ id: id,
353
+ value: value,
354
+ isHighlighted: isHighlighted,
355
+ isSelected: isSelected,
356
+ isDisabled: isDisabled,
357
+ renderBeforeLabel: getRenderLabel(renderBeforeLabel),
358
+ renderAfterLabel: getRenderLabel(renderAfterLabel),
359
+ ...(0, _passthroughProps.passthroughProps)(rest),
360
+ children: children
361
+ }, option.key || id);
362
+ }
363
+ renderGroup(group) {
364
+ const _group$props = group.props,
365
+ id = _group$props.id,
366
+ renderLabel = _group$props.renderLabel,
367
+ children = _group$props.children,
368
+ rest = (0, _objectWithoutProperties2.default)(_group$props, _excluded2);
369
+ return (0, _jsxRuntime.jsx)(_latest.Select.Group, {
370
+ renderLabel: renderLabel,
371
+ ...(0, _passthroughProps.passthroughProps)(rest),
372
+ children: _react.Children.map(children, child => this.renderOption(child))
373
+ }, group.key || id);
374
+ }
375
+ render() {
376
+ const _this$props = this.props,
377
+ renderLabel = _this$props.renderLabel,
378
+ value = _this$props.value,
379
+ defaultValue = _this$props.defaultValue,
380
+ id = _this$props.id,
381
+ size = _this$props.size,
382
+ assistiveText = _this$props.assistiveText,
383
+ placeholder = _this$props.placeholder,
384
+ interaction = _this$props.interaction,
385
+ isRequired = _this$props.isRequired,
386
+ isInline = _this$props.isInline,
387
+ width = _this$props.width,
388
+ optionsMaxWidth = _this$props.optionsMaxWidth,
389
+ optionsMaxHeight = _this$props.optionsMaxHeight,
390
+ visibleOptionsCount = _this$props.visibleOptionsCount,
391
+ messages = _this$props.messages,
392
+ placement = _this$props.placement,
393
+ constrain = _this$props.constrain,
394
+ mountNode = _this$props.mountNode,
395
+ inputRef = _this$props.inputRef,
396
+ listRef = _this$props.listRef,
397
+ renderEmptyOption = _this$props.renderEmptyOption,
398
+ renderBeforeInput = _this$props.renderBeforeInput,
399
+ renderAfterInput = _this$props.renderAfterInput,
400
+ onFocus = _this$props.onFocus,
401
+ onBlur = _this$props.onBlur,
402
+ onShowOptions = _this$props.onShowOptions,
403
+ onHideOptions = _this$props.onHideOptions,
404
+ children = _this$props.children,
405
+ layout = _this$props.layout,
406
+ rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded3);
407
+ return (0, _jsxRuntime.jsx)(_latest.Select, {
408
+ renderLabel: renderLabel,
409
+ inputValue: this.state.inputValue,
410
+ isShowingOptions: this.state.isShowingOptions,
411
+ id: id,
412
+ size: size,
413
+ assistiveText: assistiveText,
414
+ placeholder: placeholder,
415
+ interaction: this.interaction,
416
+ isRequired: isRequired,
417
+ isInline: isInline,
418
+ width: width,
419
+ optionsMaxWidth: optionsMaxWidth,
420
+ optionsMaxHeight: optionsMaxHeight,
421
+ visibleOptionsCount: visibleOptionsCount,
422
+ messages: messages,
423
+ placement: placement,
424
+ constrain: constrain,
425
+ mountNode: mountNode,
426
+ ref: this.handleRef,
427
+ inputRef: inputRef,
428
+ listRef: listRef,
429
+ renderBeforeInput: renderBeforeInput,
430
+ renderAfterInput: renderAfterInput,
431
+ onFocus: onFocus,
432
+ onBlur: this.handleBlur,
433
+ onRequestShowOptions: this.handleShowOptions,
434
+ onRequestHideOptions: this.handleHideOptions,
435
+ onRequestHighlightOption: this.handleHighlightOption,
436
+ onRequestSelectOption: this.handleSelectOption,
437
+ isOptionContentAppliedToInput: this.props.isOptionContentAppliedToInput,
438
+ layout: layout,
439
+ ...(0, _passthroughProps.passthroughProps)(rest),
440
+ "data-cid": "SimpleSelect",
441
+ children: this.renderChildren()
442
+ });
443
+ }
444
+ }, _SimpleSelect.displayName = "SimpleSelect", _SimpleSelect.componentId = 'SimpleSelect', _SimpleSelect.Option = _Option.Option, _SimpleSelect.Group = _Group.Group, _SimpleSelect.allowedProps = _props.allowedProps, _SimpleSelect.defaultProps = {
445
+ size: 'medium',
446
+ isRequired: false,
447
+ isInline: false,
448
+ visibleOptionsCount: 8,
449
+ placement: 'bottom stretch',
450
+ constrain: 'window',
451
+ renderEmptyOption: '---',
452
+ isOptionContentAppliedToInput: false
453
+ }, _SimpleSelect)) || _class);
454
+ var _default = exports.default = SimpleSelect;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['renderLabel', 'value', 'defaultValue', 'id', 'size', 'assistiveText', 'placeholder', 'interaction', 'isRequired', 'isInline', 'width', 'visibleOptionsCount', 'optionsMaxHeight', 'optionsMaxWidth', 'messages', 'placement', 'constrain', 'mountNode', 'onChange', 'onFocus', 'onBlur', 'onShowOptions', 'onHideOptions', 'inputRef', 'listRef', 'renderEmptyOption', 'renderBeforeInput', 'renderAfterInput', 'children', 'layout'];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SimpleSelect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.SimpleSelect;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "SimpleSelectGroup", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Group.Group;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "SimpleSelectOption", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _Option.Option;
22
+ }
23
+ });
24
+ var _v = require("../SimpleSelect/v2");
25
+ var _Group = require("../SimpleSelect/v2/Group");
26
+ var _Option = require("../SimpleSelect/v2/Option");