@instructure/ui-simple-select 8.25.1-snapshot-10 → 8.25.1-snapshot-15
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/Group/index.js +5 -6
- package/es/SimpleSelect/Option/index.js +7 -8
- package/es/SimpleSelect/index.js +139 -139
- package/lib/SimpleSelect/Group/index.js +5 -6
- package/lib/SimpleSelect/Option/index.js +7 -8
- package/lib/SimpleSelect/index.js +140 -140
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +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
|
-
## [8.25.1-snapshot-
|
6
|
+
## [8.25.1-snapshot-15](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-15) (2022-06-23)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-simple-select
|
9
9
|
|
@@ -32,13 +32,7 @@ id: SimpleSelect.Group
|
|
32
32
|
**/
|
33
33
|
|
34
34
|
class Group extends Component {
|
35
|
-
static displayName = "Group";
|
36
|
-
static componentId = 'SimpleSelect.Group';
|
37
|
-
static allowedProps = allowedProps;
|
38
|
-
static propTypes = propTypes;
|
39
|
-
static defaultProps = {};
|
40
35
|
/* istanbul ignore next */
|
41
|
-
|
42
36
|
render() {
|
43
37
|
// this component is only used for prop validation. Select.Group children
|
44
38
|
// are parsed in Select and rendered as Options components
|
@@ -47,5 +41,10 @@ class Group extends Component {
|
|
47
41
|
|
48
42
|
}
|
49
43
|
|
44
|
+
Group.displayName = "Group";
|
45
|
+
Group.componentId = 'SimpleSelect.Group';
|
46
|
+
Group.allowedProps = allowedProps;
|
47
|
+
Group.propTypes = propTypes;
|
48
|
+
Group.defaultProps = {};
|
50
49
|
export default Group;
|
51
50
|
export { Group };
|
@@ -32,15 +32,7 @@ id: SimpleSelect.Option
|
|
32
32
|
**/
|
33
33
|
|
34
34
|
class Option extends Component {
|
35
|
-
static displayName = "Option";
|
36
|
-
static componentId = 'SimpleSelect.Option';
|
37
|
-
static allowedProps = allowedProps;
|
38
|
-
static propTypes = propTypes;
|
39
|
-
static defaultProps = {
|
40
|
-
isDisabled: false
|
41
|
-
};
|
42
35
|
/* istanbul ignore next */
|
43
|
-
|
44
36
|
render() {
|
45
37
|
// this component is only used for prop validation. SimpleSelect.Option children
|
46
38
|
// are parsed in Select and rendered as Options.Item components
|
@@ -49,5 +41,12 @@ class Option extends Component {
|
|
49
41
|
|
50
42
|
}
|
51
43
|
|
44
|
+
Option.displayName = "Option";
|
45
|
+
Option.componentId = 'SimpleSelect.Option';
|
46
|
+
Option.allowedProps = allowedProps;
|
47
|
+
Option.propTypes = propTypes;
|
48
|
+
Option.defaultProps = {
|
49
|
+
isDisabled: false
|
50
|
+
};
|
52
51
|
export default Option;
|
53
52
|
export { Option };
|
package/es/SimpleSelect/index.js
CHANGED
@@ -3,7 +3,7 @@ const _excluded = ["id", "value", "children", "renderBeforeLabel", "renderAfterL
|
|
3
3
|
_excluded2 = ["id", "renderLabel", "children"],
|
4
4
|
_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"];
|
5
5
|
|
6
|
-
var _dec, _dec2, _class;
|
6
|
+
var _dec, _dec2, _class, _class2;
|
7
7
|
|
8
8
|
/*
|
9
9
|
* The MIT License (MIT)
|
@@ -43,33 +43,140 @@ tags: form, field, dropdown
|
|
43
43
|
---
|
44
44
|
@tsProps
|
45
45
|
**/
|
46
|
-
let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_class = _dec2(_class = class SimpleSelect extends Component {
|
47
|
-
static displayName = "SimpleSelect";
|
48
|
-
static componentId = 'SimpleSelect';
|
49
|
-
static Option = Option;
|
50
|
-
static Group = Group;
|
51
|
-
static allowedProps = allowedProps;
|
52
|
-
static propTypes = propTypes;
|
53
|
-
static defaultProps = {
|
54
|
-
size: 'medium',
|
55
|
-
isRequired: false,
|
56
|
-
isInline: false,
|
57
|
-
visibleOptionsCount: 8,
|
58
|
-
placement: 'bottom stretch',
|
59
|
-
constrain: 'window',
|
60
|
-
renderEmptyOption: '---'
|
61
|
-
};
|
62
|
-
ref = null;
|
63
|
-
_emptyOptionId;
|
64
|
-
|
46
|
+
let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class SimpleSelect extends Component {
|
65
47
|
constructor(props) {
|
66
48
|
super(props);
|
67
|
-
|
49
|
+
this.ref = null;
|
50
|
+
this._emptyOptionId = void 0;
|
51
|
+
|
52
|
+
this.getOption = (field, value) => {
|
53
|
+
const children = Children.toArray(this.props.children);
|
54
|
+
let match;
|
55
|
+
|
56
|
+
for (let i = 0; i < children.length; ++i) {
|
57
|
+
const child = children[i];
|
58
|
+
|
59
|
+
if (matchComponentTypes(child, [Option])) {
|
60
|
+
if (child.props[field] === value) {
|
61
|
+
match = child;
|
62
|
+
}
|
63
|
+
} else if (matchComponentTypes(child, [Group])) {
|
64
|
+
const groupChildren = Children.toArray(child.props.children);
|
65
|
+
|
66
|
+
for (let j = 0; j < groupChildren.length; ++j) {
|
67
|
+
const groupChild = groupChildren[j];
|
68
|
+
|
69
|
+
if (groupChild.props[field] === value) {
|
70
|
+
match = groupChild;
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
if (match) break;
|
77
|
+
}
|
78
|
+
|
79
|
+
return match;
|
80
|
+
};
|
81
|
+
|
82
|
+
this.handleRef = node => {
|
83
|
+
this.ref = node;
|
84
|
+
};
|
85
|
+
|
86
|
+
this.handleBlur = event => {
|
87
|
+
this.setState({
|
88
|
+
highlightedOptionId: void 0
|
89
|
+
});
|
90
|
+
|
91
|
+
if (typeof this.props.onBlur === 'function') {
|
92
|
+
this.props.onBlur(event);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
this.handleShowOptions = event => {
|
97
|
+
this.setState({
|
98
|
+
isShowingOptions: true
|
99
|
+
});
|
100
|
+
|
101
|
+
if (typeof this.props.onShowOptions === 'function') {
|
102
|
+
this.props.onShowOptions(event);
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
106
|
+
this.handleHideOptions = event => {
|
107
|
+
this.setState(state => {
|
108
|
+
const option = this.getOption('id', state.selectedOptionId);
|
109
|
+
return {
|
110
|
+
isShowingOptions: false,
|
111
|
+
highlightedOptionId: void 0,
|
112
|
+
inputValue: option ? option.props.children : ''
|
113
|
+
};
|
114
|
+
});
|
115
|
+
|
116
|
+
if (typeof this.props.onHideOptions === 'function') {
|
117
|
+
this.props.onHideOptions(event);
|
118
|
+
}
|
119
|
+
};
|
120
|
+
|
121
|
+
this.handleHighlightOption = (event, _ref) => {
|
122
|
+
let id = _ref.id;
|
123
|
+
if (id === this._emptyOptionId) return;
|
124
|
+
const option = this.getOption('id', id);
|
125
|
+
const label = option === null || option === void 0 ? void 0 : option.props.children;
|
126
|
+
const inputValue = event.type === 'keydown' ? label : this.state.inputValue;
|
127
|
+
this.setState({
|
128
|
+
highlightedOptionId: id,
|
129
|
+
inputValue
|
130
|
+
});
|
131
|
+
};
|
132
|
+
|
133
|
+
this.handleSelectOption = (event, _ref2) => {
|
134
|
+
let id = _ref2.id;
|
135
|
+
|
136
|
+
if (id === this._emptyOptionId) {
|
137
|
+
// selected option is the empty option
|
138
|
+
this.setState({
|
139
|
+
isShowingOptions: false
|
140
|
+
});
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
144
|
+
const option = this.getOption('id', id);
|
145
|
+
const value = option && option.props.value;
|
146
|
+
|
147
|
+
if (this.isControlled) {
|
148
|
+
this.setState({
|
149
|
+
isShowingOptions: false
|
150
|
+
});
|
151
|
+
} else {
|
152
|
+
this.setState(state => ({
|
153
|
+
isShowingOptions: false,
|
154
|
+
selectedOptionId: id,
|
155
|
+
inputValue: option ? option.props.children : state.inputValue
|
156
|
+
}));
|
157
|
+
} // fire onChange if selected option changed
|
158
|
+
|
159
|
+
|
160
|
+
if (option && typeof this.props.onChange === 'function') {
|
161
|
+
this.props.onChange(event, {
|
162
|
+
value,
|
163
|
+
id
|
164
|
+
});
|
165
|
+
} // hide options list whenever selection is made
|
166
|
+
|
167
|
+
|
168
|
+
if (typeof this.props.onHideOptions === 'function') {
|
169
|
+
this.props.onHideOptions(event);
|
170
|
+
}
|
171
|
+
};
|
172
|
+
|
173
|
+
const _option = this.getInitialOption(props);
|
174
|
+
|
68
175
|
this.state = {
|
69
|
-
inputValue:
|
176
|
+
inputValue: _option ? _option.props.children : '',
|
70
177
|
isShowingOptions: false,
|
71
178
|
highlightedOptionId: void 0,
|
72
|
-
selectedOptionId:
|
179
|
+
selectedOptionId: _option ? _option.props.id : void 0
|
73
180
|
};
|
74
181
|
this._emptyOptionId = props.deterministicId('Select-EmptyOption');
|
75
182
|
}
|
@@ -157,121 +264,6 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
157
264
|
return match;
|
158
265
|
}
|
159
266
|
|
160
|
-
getOption = (field, value) => {
|
161
|
-
const children = Children.toArray(this.props.children);
|
162
|
-
let match;
|
163
|
-
|
164
|
-
for (let i = 0; i < children.length; ++i) {
|
165
|
-
const child = children[i];
|
166
|
-
|
167
|
-
if (matchComponentTypes(child, [Option])) {
|
168
|
-
if (child.props[field] === value) {
|
169
|
-
match = child;
|
170
|
-
}
|
171
|
-
} else if (matchComponentTypes(child, [Group])) {
|
172
|
-
const groupChildren = Children.toArray(child.props.children);
|
173
|
-
|
174
|
-
for (let j = 0; j < groupChildren.length; ++j) {
|
175
|
-
const groupChild = groupChildren[j];
|
176
|
-
|
177
|
-
if (groupChild.props[field] === value) {
|
178
|
-
match = groupChild;
|
179
|
-
break;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
if (match) break;
|
185
|
-
}
|
186
|
-
|
187
|
-
return match;
|
188
|
-
};
|
189
|
-
handleRef = node => {
|
190
|
-
this.ref = node;
|
191
|
-
};
|
192
|
-
handleBlur = event => {
|
193
|
-
this.setState({
|
194
|
-
highlightedOptionId: void 0
|
195
|
-
});
|
196
|
-
|
197
|
-
if (typeof this.props.onBlur === 'function') {
|
198
|
-
this.props.onBlur(event);
|
199
|
-
}
|
200
|
-
};
|
201
|
-
handleShowOptions = event => {
|
202
|
-
this.setState({
|
203
|
-
isShowingOptions: true
|
204
|
-
});
|
205
|
-
|
206
|
-
if (typeof this.props.onShowOptions === 'function') {
|
207
|
-
this.props.onShowOptions(event);
|
208
|
-
}
|
209
|
-
};
|
210
|
-
handleHideOptions = event => {
|
211
|
-
this.setState(state => {
|
212
|
-
const option = this.getOption('id', state.selectedOptionId);
|
213
|
-
return {
|
214
|
-
isShowingOptions: false,
|
215
|
-
highlightedOptionId: void 0,
|
216
|
-
inputValue: option ? option.props.children : ''
|
217
|
-
};
|
218
|
-
});
|
219
|
-
|
220
|
-
if (typeof this.props.onHideOptions === 'function') {
|
221
|
-
this.props.onHideOptions(event);
|
222
|
-
}
|
223
|
-
};
|
224
|
-
handleHighlightOption = (event, _ref) => {
|
225
|
-
let id = _ref.id;
|
226
|
-
if (id === this._emptyOptionId) return;
|
227
|
-
const option = this.getOption('id', id);
|
228
|
-
const label = option === null || option === void 0 ? void 0 : option.props.children;
|
229
|
-
const inputValue = event.type === 'keydown' ? label : this.state.inputValue;
|
230
|
-
this.setState({
|
231
|
-
highlightedOptionId: id,
|
232
|
-
inputValue
|
233
|
-
});
|
234
|
-
};
|
235
|
-
handleSelectOption = (event, _ref2) => {
|
236
|
-
let id = _ref2.id;
|
237
|
-
|
238
|
-
if (id === this._emptyOptionId) {
|
239
|
-
// selected option is the empty option
|
240
|
-
this.setState({
|
241
|
-
isShowingOptions: false
|
242
|
-
});
|
243
|
-
return;
|
244
|
-
}
|
245
|
-
|
246
|
-
const option = this.getOption('id', id);
|
247
|
-
const value = option && option.props.value;
|
248
|
-
|
249
|
-
if (this.isControlled) {
|
250
|
-
this.setState({
|
251
|
-
isShowingOptions: false
|
252
|
-
});
|
253
|
-
} else {
|
254
|
-
this.setState(state => ({
|
255
|
-
isShowingOptions: false,
|
256
|
-
selectedOptionId: id,
|
257
|
-
inputValue: option ? option.props.children : state.inputValue
|
258
|
-
}));
|
259
|
-
} // fire onChange if selected option changed
|
260
|
-
|
261
|
-
|
262
|
-
if (option && typeof this.props.onChange === 'function') {
|
263
|
-
this.props.onChange(event, {
|
264
|
-
value,
|
265
|
-
id
|
266
|
-
});
|
267
|
-
} // hide options list whenever selection is made
|
268
|
-
|
269
|
-
|
270
|
-
if (typeof this.props.onHideOptions === 'function') {
|
271
|
-
this.props.onHideOptions(event);
|
272
|
-
}
|
273
|
-
};
|
274
|
-
|
275
267
|
renderChildren() {
|
276
268
|
let children = Children.toArray(this.props.children);
|
277
269
|
children = Children.map(children, child => {
|
@@ -415,6 +407,14 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
415
407
|
}, passthroughProps(rest)), this.renderChildren());
|
416
408
|
}
|
417
409
|
|
418
|
-
}
|
410
|
+
}, _class2.displayName = "SimpleSelect", _class2.componentId = 'SimpleSelect', _class2.Option = Option, _class2.Group = Group, _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
411
|
+
size: 'medium',
|
412
|
+
isRequired: false,
|
413
|
+
isInline: false,
|
414
|
+
visibleOptionsCount: 8,
|
415
|
+
placement: 'bottom stretch',
|
416
|
+
constrain: 'window',
|
417
|
+
renderEmptyOption: '---'
|
418
|
+
}, _class2)) || _class) || _class);
|
419
419
|
export { SimpleSelect };
|
420
420
|
export default SimpleSelect;
|
@@ -41,13 +41,7 @@ id: SimpleSelect.Group
|
|
41
41
|
@tsProps
|
42
42
|
**/
|
43
43
|
class Group extends _react.Component {
|
44
|
-
static displayName = "Group";
|
45
|
-
static componentId = 'SimpleSelect.Group';
|
46
|
-
static allowedProps = _props.allowedProps;
|
47
|
-
static propTypes = _props.propTypes;
|
48
|
-
static defaultProps = {};
|
49
44
|
/* istanbul ignore next */
|
50
|
-
|
51
45
|
render() {
|
52
46
|
// this component is only used for prop validation. Select.Group children
|
53
47
|
// are parsed in Select and rendered as Options components
|
@@ -57,5 +51,10 @@ class Group extends _react.Component {
|
|
57
51
|
}
|
58
52
|
|
59
53
|
exports.Group = Group;
|
54
|
+
Group.displayName = "Group";
|
55
|
+
Group.componentId = 'SimpleSelect.Group';
|
56
|
+
Group.allowedProps = _props.allowedProps;
|
57
|
+
Group.propTypes = _props.propTypes;
|
58
|
+
Group.defaultProps = {};
|
60
59
|
var _default = Group;
|
61
60
|
exports.default = _default;
|
@@ -41,15 +41,7 @@ id: SimpleSelect.Option
|
|
41
41
|
@tsProps
|
42
42
|
**/
|
43
43
|
class Option extends _react.Component {
|
44
|
-
static displayName = "Option";
|
45
|
-
static componentId = 'SimpleSelect.Option';
|
46
|
-
static allowedProps = _props.allowedProps;
|
47
|
-
static propTypes = _props.propTypes;
|
48
|
-
static defaultProps = {
|
49
|
-
isDisabled: false
|
50
|
-
};
|
51
44
|
/* istanbul ignore next */
|
52
|
-
|
53
45
|
render() {
|
54
46
|
// this component is only used for prop validation. SimpleSelect.Option children
|
55
47
|
// are parsed in Select and rendered as Options.Item components
|
@@ -59,5 +51,12 @@ class Option extends _react.Component {
|
|
59
51
|
}
|
60
52
|
|
61
53
|
exports.Option = Option;
|
54
|
+
Option.displayName = "Option";
|
55
|
+
Option.componentId = 'SimpleSelect.Option';
|
56
|
+
Option.allowedProps = _props.allowedProps;
|
57
|
+
Option.propTypes = _props.propTypes;
|
58
|
+
Option.defaultProps = {
|
59
|
+
isDisabled: false
|
60
|
+
};
|
62
61
|
var _default = Option;
|
63
62
|
exports.default = _default;
|