@instructure/ui-simple-select 8.14.1-snapshot.5 → 8.14.1-snapshot.68
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/es/SimpleSelect/Group/index.js +2 -3
- package/es/SimpleSelect/Group/props.js +0 -7
- package/es/SimpleSelect/Option/index.js +2 -2
- package/es/SimpleSelect/Option/props.js +0 -23
- package/es/SimpleSelect/SimpleSelectLocator.js +3 -1
- package/es/SimpleSelect/__examples__/SimpleSelect.examples.js +2 -2
- package/es/SimpleSelect/index.js +74 -68
- package/es/SimpleSelect/props.js +0 -130
- package/lib/SimpleSelect/Group/index.js +2 -3
- package/lib/SimpleSelect/Group/props.js +0 -7
- package/lib/SimpleSelect/Option/index.js +2 -2
- package/lib/SimpleSelect/Option/props.js +0 -23
- package/lib/SimpleSelect/SimpleSelectLocator.js +2 -0
- package/lib/SimpleSelect/__examples__/SimpleSelect.examples.js +2 -2
- package/lib/SimpleSelect/index.js +73 -70
- package/lib/SimpleSelect/props.js +0 -130
- package/package.json +15 -15
- package/src/SimpleSelect/Group/index.tsx +3 -4
- package/src/SimpleSelect/Group/props.ts +10 -8
- package/src/SimpleSelect/Option/index.tsx +2 -2
- package/src/SimpleSelect/Option/props.ts +35 -21
- package/src/SimpleSelect/__examples__/SimpleSelect.examples.tsx +7 -5
- package/src/SimpleSelect/index.tsx +88 -111
- package/src/SimpleSelect/props.ts +147 -94
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SimpleSelect/Group/index.d.ts +4 -5
- package/types/SimpleSelect/Group/index.d.ts.map +1 -1
- package/types/SimpleSelect/Group/props.d.ts +7 -1
- package/types/SimpleSelect/Group/props.d.ts.map +1 -1
- package/types/SimpleSelect/Option/index.d.ts +7 -7
- package/types/SimpleSelect/Option/index.d.ts.map +1 -1
- package/types/SimpleSelect/Option/props.d.ts +30 -4
- package/types/SimpleSelect/Option/props.d.ts.map +1 -1
- package/types/SimpleSelect/SimpleSelectLocator.d.ts +4 -4
- package/types/SimpleSelect/__examples__/SimpleSelect.examples.d.ts +3 -14
- package/types/SimpleSelect/__examples__/SimpleSelect.examples.d.ts.map +1 -1
- package/types/SimpleSelect/index.d.ts +45 -61
- package/types/SimpleSelect/index.d.ts.map +1 -1
- package/types/SimpleSelect/props.d.ts +127 -16
- package/types/SimpleSelect/props.d.ts.map +1 -1
|
@@ -44,12 +44,42 @@ var _dec, _class, _class2, _temp;
|
|
|
44
44
|
category: components
|
|
45
45
|
tags: form, field, dropdown
|
|
46
46
|
---
|
|
47
|
+
@tsProps
|
|
47
48
|
**/
|
|
48
49
|
let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _class2 = class SimpleSelect extends _react.Component {
|
|
49
50
|
constructor(props) {
|
|
50
51
|
super(props);
|
|
51
52
|
this.ref = null;
|
|
52
|
-
this._emptyOptionId =
|
|
53
|
+
this._emptyOptionId = void 0;
|
|
54
|
+
|
|
55
|
+
this.getOption = (field, value) => {
|
|
56
|
+
let match;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < this.childrenArray.length; ++i) {
|
|
59
|
+
const child = this.childrenArray[i];
|
|
60
|
+
|
|
61
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
|
|
62
|
+
if (child.props[field] === value) {
|
|
63
|
+
match = child;
|
|
64
|
+
}
|
|
65
|
+
} else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
66
|
+
const groupChildren = _react.Children.toArray(child.props.children);
|
|
67
|
+
|
|
68
|
+
for (let j = 0; j < groupChildren.length; ++j) {
|
|
69
|
+
const groupChild = groupChildren[j];
|
|
70
|
+
|
|
71
|
+
if (groupChild.props[field] === value) {
|
|
72
|
+
match = groupChild;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (match) break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return match;
|
|
82
|
+
};
|
|
53
83
|
|
|
54
84
|
this.handleRef = node => {
|
|
55
85
|
this.ref = node;
|
|
@@ -57,16 +87,22 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
57
87
|
|
|
58
88
|
this.handleBlur = event => {
|
|
59
89
|
this.setState({
|
|
60
|
-
highlightedOptionId:
|
|
90
|
+
highlightedOptionId: void 0
|
|
61
91
|
});
|
|
62
|
-
|
|
92
|
+
|
|
93
|
+
if (typeof this.props.onBlur === 'function') {
|
|
94
|
+
this.props.onBlur(event);
|
|
95
|
+
}
|
|
63
96
|
};
|
|
64
97
|
|
|
65
98
|
this.handleShowOptions = event => {
|
|
66
99
|
this.setState({
|
|
67
100
|
isShowingOptions: true
|
|
68
101
|
});
|
|
69
|
-
|
|
102
|
+
|
|
103
|
+
if (typeof this.props.onShowOptions === 'function') {
|
|
104
|
+
this.props.onShowOptions(event);
|
|
105
|
+
}
|
|
70
106
|
};
|
|
71
107
|
|
|
72
108
|
this.handleHideOptions = event => {
|
|
@@ -74,18 +110,21 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
74
110
|
const option = this.getOption('id', state.selectedOptionId);
|
|
75
111
|
return {
|
|
76
112
|
isShowingOptions: false,
|
|
77
|
-
highlightedOptionId:
|
|
113
|
+
highlightedOptionId: void 0,
|
|
78
114
|
inputValue: option ? option.props.children : ''
|
|
79
115
|
};
|
|
80
116
|
});
|
|
81
|
-
|
|
117
|
+
|
|
118
|
+
if (typeof this.props.onHideOptions === 'function') {
|
|
119
|
+
this.props.onHideOptions(event);
|
|
120
|
+
}
|
|
82
121
|
};
|
|
83
122
|
|
|
84
123
|
this.handleHighlightOption = (event, _ref) => {
|
|
85
124
|
let id = _ref.id;
|
|
86
125
|
if (id === this._emptyOptionId) return;
|
|
87
126
|
const option = this.getOption('id', id);
|
|
88
|
-
const label = option.props.children;
|
|
127
|
+
const label = option === null || option === void 0 ? void 0 : option.props.children;
|
|
89
128
|
const inputValue = event.type === 'keydown' ? label : this.state.inputValue;
|
|
90
129
|
this.setState({
|
|
91
130
|
highlightedOptionId: id,
|
|
@@ -120,12 +159,17 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
120
159
|
} // fire onChange if selected option changed
|
|
121
160
|
|
|
122
161
|
|
|
123
|
-
option && this.props.onChange
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
162
|
+
if (option && typeof this.props.onChange === 'function') {
|
|
163
|
+
this.props.onChange(event, {
|
|
164
|
+
value,
|
|
165
|
+
id
|
|
166
|
+
});
|
|
167
|
+
} // hide options list whenever selection is made
|
|
127
168
|
|
|
128
|
-
|
|
169
|
+
|
|
170
|
+
if (typeof this.props.onHideOptions === 'function') {
|
|
171
|
+
this.props.onHideOptions(event);
|
|
172
|
+
}
|
|
129
173
|
};
|
|
130
174
|
|
|
131
175
|
const _option = this.getInitialOption(props);
|
|
@@ -133,25 +177,30 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
133
177
|
this.state = {
|
|
134
178
|
inputValue: _option ? _option.props.children : '',
|
|
135
179
|
isShowingOptions: false,
|
|
136
|
-
highlightedOptionId:
|
|
137
|
-
selectedOptionId: _option ? _option.props.id :
|
|
180
|
+
highlightedOptionId: void 0,
|
|
181
|
+
selectedOptionId: _option ? _option.props.id : void 0
|
|
138
182
|
};
|
|
183
|
+
this._emptyOptionId = (0, _uid.uid)('Select-EmptyOption');
|
|
139
184
|
}
|
|
140
185
|
|
|
141
186
|
get _select() {
|
|
142
187
|
return this.ref;
|
|
143
188
|
}
|
|
144
189
|
|
|
190
|
+
get childrenArray() {
|
|
191
|
+
return _react.Children.toArray(this.props.children);
|
|
192
|
+
}
|
|
193
|
+
|
|
145
194
|
focus() {
|
|
146
195
|
this.ref && this.ref.focus();
|
|
147
196
|
}
|
|
148
197
|
|
|
149
198
|
get focused() {
|
|
150
|
-
return this.ref
|
|
199
|
+
return this.ref ? this.ref.focused : false;
|
|
151
200
|
}
|
|
152
201
|
|
|
153
202
|
get id() {
|
|
154
|
-
return this.ref
|
|
203
|
+
return this.ref ? this.ref.id : void 0;
|
|
155
204
|
}
|
|
156
205
|
|
|
157
206
|
get isControlled() {
|
|
@@ -191,7 +240,7 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
191
240
|
} // otherwise get the first option
|
|
192
241
|
|
|
193
242
|
|
|
194
|
-
return this.
|
|
243
|
+
return this.getFirstOption();
|
|
195
244
|
}
|
|
196
245
|
|
|
197
246
|
getOptionLabelById(id) {
|
|
@@ -199,13 +248,11 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
199
248
|
return option ? option.props.children : '';
|
|
200
249
|
}
|
|
201
250
|
|
|
202
|
-
|
|
203
|
-
|
|
251
|
+
getFirstOption() {
|
|
252
|
+
let match;
|
|
204
253
|
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
for (let i = 0; i < children.length; i++) {
|
|
208
|
-
const child = children[i];
|
|
254
|
+
for (let i = 0; i < this.childrenArray.length; i++) {
|
|
255
|
+
const child = this.childrenArray[i];
|
|
209
256
|
|
|
210
257
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
|
|
211
258
|
match = child;
|
|
@@ -222,41 +269,8 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
222
269
|
return match;
|
|
223
270
|
}
|
|
224
271
|
|
|
225
|
-
getOption(field, value) {
|
|
226
|
-
const children = _react.Children.toArray(this.props.children);
|
|
227
|
-
|
|
228
|
-
let match = null;
|
|
229
|
-
|
|
230
|
-
for (let i = 0; i < children.length; ++i) {
|
|
231
|
-
const child = children[i];
|
|
232
|
-
|
|
233
|
-
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
|
|
234
|
-
if (child.props[field] === value) {
|
|
235
|
-
match = child;
|
|
236
|
-
}
|
|
237
|
-
} else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
238
|
-
const groupChildren = _react.Children.toArray(child.props.children);
|
|
239
|
-
|
|
240
|
-
for (let j = 0; j < groupChildren.length; ++j) {
|
|
241
|
-
const groupChild = groupChildren[j];
|
|
242
|
-
|
|
243
|
-
if (groupChild.props[field] === value) {
|
|
244
|
-
match = groupChild;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (match) break;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return match;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
272
|
renderChildren() {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
children = _react.Children.map(children, child => {
|
|
273
|
+
const children = _react.Children.map(this.childrenArray, child => {
|
|
260
274
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
|
|
261
275
|
return this.renderOption(child);
|
|
262
276
|
} else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
@@ -387,28 +401,17 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
387
401
|
onRequestHideOptions: this.handleHideOptions,
|
|
388
402
|
onRequestHighlightOption: this.handleHighlightOption,
|
|
389
403
|
onRequestSelectOption: this.handleSelectOption
|
|
390
|
-
}, (0, _passthroughProps.passthroughProps)(rest)), this.renderChildren(
|
|
404
|
+
}, (0, _passthroughProps.passthroughProps)(rest)), this.renderChildren());
|
|
391
405
|
}
|
|
392
406
|
|
|
393
407
|
}, _class2.displayName = "SimpleSelect", _class2.componentId = 'SimpleSelect', _class2.Option = _Option.Option, _class2.Group = _Group.Group, _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
394
408
|
size: 'medium',
|
|
395
|
-
placeholder: null,
|
|
396
409
|
isRequired: false,
|
|
397
410
|
isInline: false,
|
|
398
411
|
visibleOptionsCount: 8,
|
|
399
412
|
placement: 'bottom stretch',
|
|
400
413
|
constrain: 'window',
|
|
401
|
-
|
|
402
|
-
onFocus: event => {},
|
|
403
|
-
onBlur: event => {},
|
|
404
|
-
onShowOptions: event => {},
|
|
405
|
-
onHideOptions: event => {},
|
|
406
|
-
inputRef: node => {},
|
|
407
|
-
listRef: node => {},
|
|
408
|
-
renderEmptyOption: '---',
|
|
409
|
-
renderBeforeInput: null,
|
|
410
|
-
renderAfterInput: null,
|
|
411
|
-
children: null
|
|
414
|
+
renderEmptyOption: '---'
|
|
412
415
|
}, _temp)) || _class);
|
|
413
416
|
exports.SimpleSelect = SimpleSelect;
|
|
414
417
|
var _default = SimpleSelect;
|
|
@@ -43,164 +43,34 @@ var _Option = require("./Option");
|
|
|
43
43
|
* SOFTWARE.
|
|
44
44
|
*/
|
|
45
45
|
const propTypes = {
|
|
46
|
-
/**
|
|
47
|
-
* The form field label.
|
|
48
|
-
*/
|
|
49
46
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The value corresponding to the value of the selected option. If defined,
|
|
53
|
-
* the component will act controlled and will not manage its own state.
|
|
54
|
-
*/
|
|
55
47
|
// TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
|
|
56
48
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The value of the option to select by default, when uncontrolled.
|
|
60
|
-
*/
|
|
61
49
|
defaultValue: _propTypes.default.string,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The id of the text input. One is generated if not supplied.
|
|
65
|
-
*/
|
|
66
50
|
id: _propTypes.default.string,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The size of the text input.
|
|
70
|
-
*/
|
|
71
51
|
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Additional helpful text to provide to screen readers about the operation
|
|
75
|
-
* of the component. Provided via aria-describedby.
|
|
76
|
-
*/
|
|
77
52
|
assistiveText: _propTypes.default.string,
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Html placeholder text to display when the input has no value. This should
|
|
81
|
-
* be hint text, not a label replacement.
|
|
82
|
-
*/
|
|
83
53
|
placeholder: _propTypes.default.string,
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
87
|
-
* When "disabled", the input changes visibly to indicate that it cannot
|
|
88
|
-
* receive user interactions. When "readonly" the input still cannot receive
|
|
89
|
-
* user interactions but it keeps the same styles as if it were enabled.
|
|
90
|
-
*/
|
|
91
54
|
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Whether or not the text input is required.
|
|
95
|
-
*/
|
|
96
55
|
isRequired: _propTypes.default.bool,
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Whether the input is rendered inline with other elements or if it
|
|
100
|
-
* is rendered as a block level element.
|
|
101
|
-
*/
|
|
102
56
|
isInline: _propTypes.default.bool,
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The width of the text input.
|
|
106
|
-
*/
|
|
107
57
|
width: _propTypes.default.string,
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The max width the options list can be before option text wraps. If not
|
|
111
|
-
* set, the list will only display as wide as the text input.
|
|
112
|
-
*/
|
|
113
58
|
optionsMaxWidth: _propTypes.default.string,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The number of options that should be visible before having to scroll.
|
|
117
|
-
*/
|
|
118
59
|
visibleOptionsCount: _propTypes.default.number,
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Displays messages and validation for the input. It should be an object
|
|
122
|
-
* with the following shape:
|
|
123
|
-
* `{
|
|
124
|
-
* text: PropTypes.node,
|
|
125
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
126
|
-
* }`
|
|
127
|
-
*/
|
|
128
60
|
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The placement of the options list.
|
|
132
|
-
*/
|
|
133
61
|
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* The parent in which to constrain the placement.
|
|
137
|
-
*/
|
|
138
62
|
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* An element or a function returning an element to use mount the options
|
|
142
|
-
* list to in the DOM (defaults to `document.body`)
|
|
143
|
-
*/
|
|
144
63
|
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Callback fired when a new option is selected.
|
|
148
|
-
* @param {Object} event - the event object
|
|
149
|
-
* @param {Object} data - additional data
|
|
150
|
-
* @param data.value - the value of selected option
|
|
151
|
-
* @param data.id - the id of the selected option
|
|
152
|
-
*/
|
|
153
64
|
onChange: _propTypes.default.func,
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Callback fired when text input receives focus.
|
|
157
|
-
*/
|
|
158
65
|
onFocus: _propTypes.default.func,
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Callback fired when text input loses focus.
|
|
162
|
-
*/
|
|
163
66
|
onBlur: _propTypes.default.func,
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Callback fired when the options list is shown.
|
|
167
|
-
*/
|
|
168
67
|
onShowOptions: _propTypes.default.func,
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Callback fired when the options list is hidden.
|
|
172
|
-
*/
|
|
173
68
|
onHideOptions: _propTypes.default.func,
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* A ref to the html `input` element.
|
|
177
|
-
*/
|
|
178
69
|
inputRef: _propTypes.default.func,
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* A ref to the html `ul` element.
|
|
182
|
-
*/
|
|
183
70
|
listRef: _propTypes.default.func,
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Content to display in the list when no options are available.
|
|
187
|
-
*/
|
|
188
71
|
renderEmptyOption: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Content to display before the text input. This will commonly be an icon.
|
|
192
|
-
*/
|
|
193
72
|
renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Content to display after the text input. This content will replace the
|
|
197
|
-
* default arrow icons.
|
|
198
|
-
*/
|
|
199
73
|
renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
|
|
203
|
-
*/
|
|
204
74
|
children: _Children.Children.oneOf([_Group.Group, _Option.Option])
|
|
205
75
|
};
|
|
206
76
|
exports.propTypes = propTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-simple-select",
|
|
3
|
-
"version": "8.14.1-snapshot.
|
|
3
|
+
"version": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
4
4
|
"description": "A component for standard select element behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/console": "8.14.1-snapshot.
|
|
29
|
-
"@instructure/ui-form-field": "8.14.1-snapshot.
|
|
30
|
-
"@instructure/ui-position": "8.14.1-snapshot.
|
|
31
|
-
"@instructure/ui-prop-types": "8.14.1-snapshot.
|
|
32
|
-
"@instructure/ui-react-utils": "8.14.1-snapshot.
|
|
33
|
-
"@instructure/ui-select": "8.14.1-snapshot.
|
|
34
|
-
"@instructure/ui-testable": "8.14.1-snapshot.
|
|
35
|
-
"@instructure/uid": "8.14.1-snapshot.
|
|
28
|
+
"@instructure/console": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
29
|
+
"@instructure/ui-form-field": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
30
|
+
"@instructure/ui-position": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
31
|
+
"@instructure/ui-prop-types": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
32
|
+
"@instructure/ui-react-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
33
|
+
"@instructure/ui-select": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
34
|
+
"@instructure/ui-testable": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
35
|
+
"@instructure/uid": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
36
36
|
"prop-types": "^15"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-babel-preset": "8.14.1-snapshot.
|
|
40
|
-
"@instructure/ui-color-utils": "8.14.1-snapshot.
|
|
41
|
-
"@instructure/ui-icons": "8.14.1-snapshot.
|
|
42
|
-
"@instructure/ui-test-locator": "8.14.1-snapshot.
|
|
43
|
-
"@instructure/ui-test-utils": "8.14.1-snapshot.
|
|
39
|
+
"@instructure/ui-babel-preset": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
40
|
+
"@instructure/ui-color-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
41
|
+
"@instructure/ui-icons": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
42
|
+
"@instructure/ui-test-locator": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
43
|
+
"@instructure/ui-test-utils": "8.14.1-snapshot.68+a2cfa0cd8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=16.8 <=17"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a2cfa0cd8bf43d6072f1b352bbd6e43542081be8"
|
|
53
53
|
}
|
|
@@ -32,15 +32,14 @@ import { allowedProps, propTypes } from './props'
|
|
|
32
32
|
parent: SimpleSelect
|
|
33
33
|
id: SimpleSelect.Group
|
|
34
34
|
---
|
|
35
|
+
@tsProps
|
|
35
36
|
**/
|
|
36
37
|
class Group extends Component<SimpleSelectGroupProps> {
|
|
37
38
|
static readonly componentId = 'SimpleSelect.Group'
|
|
39
|
+
|
|
38
40
|
static allowedProps = allowedProps
|
|
39
41
|
static propTypes = propTypes
|
|
40
|
-
|
|
41
|
-
static defaultProps = {
|
|
42
|
-
children: null
|
|
43
|
-
}
|
|
42
|
+
static defaultProps = {}
|
|
44
43
|
|
|
45
44
|
/* istanbul ignore next */
|
|
46
45
|
render() {
|
|
@@ -21,6 +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
25
|
import React from 'react'
|
|
25
26
|
import PropTypes from 'prop-types'
|
|
26
27
|
|
|
@@ -34,9 +35,16 @@ import type {
|
|
|
34
35
|
} from '@instructure/shared-types'
|
|
35
36
|
|
|
36
37
|
type SimpleSelectGroupOwnProps = {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The label associated with the group options.
|
|
40
|
+
*/
|
|
41
|
+
renderLabel: React.ReactNode | (() => React.ReactNode)
|
|
42
|
+
/**
|
|
43
|
+
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
44
|
+
*/
|
|
45
|
+
children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Option])
|
|
39
46
|
}
|
|
47
|
+
|
|
40
48
|
type PropKeys = keyof SimpleSelectGroupOwnProps
|
|
41
49
|
|
|
42
50
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
@@ -45,13 +53,7 @@ type SimpleSelectGroupProps = SimpleSelectGroupOwnProps &
|
|
|
45
53
|
OtherHTMLAttributes<SimpleSelectGroupOwnProps>
|
|
46
54
|
|
|
47
55
|
const propTypes: PropValidators<PropKeys> = {
|
|
48
|
-
/**
|
|
49
|
-
* The label associated with the group options.
|
|
50
|
-
*/
|
|
51
56
|
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
52
|
-
/**
|
|
53
|
-
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
54
|
-
*/
|
|
55
57
|
children: ChildrenPropTypes.oneOf([Option])
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -31,6 +31,7 @@ import { allowedProps, propTypes } from './props'
|
|
|
31
31
|
parent: SimpleSelect
|
|
32
32
|
id: SimpleSelect.Option
|
|
33
33
|
---
|
|
34
|
+
@tsProps
|
|
34
35
|
**/
|
|
35
36
|
class Option extends Component<SimpleSelectOptionProps> {
|
|
36
37
|
static readonly componentId = 'SimpleSelect.Option'
|
|
@@ -38,8 +39,7 @@ class Option extends Component<SimpleSelectOptionProps> {
|
|
|
38
39
|
static allowedProps = allowedProps
|
|
39
40
|
static propTypes = propTypes
|
|
40
41
|
static defaultProps = {
|
|
41
|
-
isDisabled: false
|
|
42
|
-
children: null
|
|
42
|
+
isDisabled: false
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/* istanbul ignore next */
|
|
@@ -21,6 +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
25
|
import React from 'react'
|
|
25
26
|
import PropTypes from 'prop-types'
|
|
26
27
|
|
|
@@ -29,45 +30,58 @@ import type {
|
|
|
29
30
|
PropValidators
|
|
30
31
|
} from '@instructure/shared-types'
|
|
31
32
|
|
|
32
|
-
type
|
|
33
|
-
id:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children?: React.ReactNode
|
|
33
|
+
type OptionProps = {
|
|
34
|
+
id: SimpleSelectOptionOwnProps['id']
|
|
35
|
+
isDisabled: SimpleSelectOptionOwnProps['isDisabled']
|
|
36
|
+
isSelected: boolean
|
|
37
|
+
isHighlighted: boolean
|
|
38
|
+
children: SimpleSelectOptionOwnProps['children']
|
|
39
39
|
}
|
|
40
|
-
type PropKeys = keyof SimpleSelectOptionOwnProps
|
|
41
|
-
|
|
42
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
43
40
|
|
|
44
|
-
type
|
|
45
|
-
|
|
41
|
+
type RenderSimpleSelectOptionLabel =
|
|
42
|
+
| React.ReactNode
|
|
43
|
+
| ((args: OptionProps) => React.ReactNode)
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
type SimpleSelectOptionOwnProps = {
|
|
48
46
|
/**
|
|
49
47
|
* The id for the option.
|
|
50
48
|
*/
|
|
51
|
-
id:
|
|
49
|
+
id: string
|
|
52
50
|
/**
|
|
53
51
|
* The value for the option.
|
|
54
52
|
*/
|
|
55
|
-
value:
|
|
53
|
+
value: string | number
|
|
56
54
|
/**
|
|
57
55
|
* Whether or not this option is disabled.
|
|
58
56
|
*/
|
|
59
|
-
isDisabled
|
|
57
|
+
isDisabled?: boolean
|
|
58
|
+
/**
|
|
59
|
+
* Content to display as the option label.
|
|
60
|
+
*/
|
|
61
|
+
children?: string
|
|
60
62
|
/**
|
|
61
63
|
* Content to display before the option label, such as an icon.
|
|
62
64
|
*/
|
|
63
|
-
renderBeforeLabel
|
|
65
|
+
renderBeforeLabel?: RenderSimpleSelectOptionLabel
|
|
64
66
|
/**
|
|
65
67
|
* Content to display after the option label, such as an icon.
|
|
66
68
|
*/
|
|
69
|
+
renderAfterLabel?: RenderSimpleSelectOptionLabel
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type PropKeys = keyof SimpleSelectOptionOwnProps
|
|
73
|
+
|
|
74
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
75
|
+
|
|
76
|
+
type SimpleSelectOptionProps = SimpleSelectOptionOwnProps &
|
|
77
|
+
OtherHTMLAttributes<SimpleSelectOptionOwnProps>
|
|
78
|
+
|
|
79
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
80
|
+
id: PropTypes.string.isRequired,
|
|
81
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
82
|
+
isDisabled: PropTypes.bool,
|
|
83
|
+
renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
67
84
|
renderAfterLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
68
|
-
/**
|
|
69
|
-
* Content to display as the option label.
|
|
70
|
-
*/
|
|
71
85
|
children: PropTypes.string
|
|
72
86
|
}
|
|
73
87
|
|
|
@@ -80,5 +94,5 @@ const allowedProps: AllowedPropKeys = [
|
|
|
80
94
|
'children'
|
|
81
95
|
]
|
|
82
96
|
|
|
83
|
-
export type { SimpleSelectOptionProps }
|
|
97
|
+
export type { SimpleSelectOptionProps, RenderSimpleSelectOptionLabel }
|
|
84
98
|
export { propTypes, allowedProps }
|
|
@@ -23,8 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
|
|
26
27
|
import { SimpleSelect } from '../../SimpleSelect'
|
|
27
28
|
|
|
29
|
+
import type { StoryConfig } from '@instructure/ui-test-utils'
|
|
30
|
+
import type { SimpleSelectProps } from '../props'
|
|
31
|
+
|
|
28
32
|
export default {
|
|
29
33
|
sectionProp: 'size',
|
|
30
34
|
maxExamplesPerPage: 50,
|
|
@@ -64,19 +68,17 @@ export default {
|
|
|
64
68
|
]
|
|
65
69
|
]
|
|
66
70
|
},
|
|
67
|
-
|
|
68
|
-
getComponentProps: (props) => {
|
|
71
|
+
getComponentProps: () => {
|
|
69
72
|
return {
|
|
70
|
-
inputValue:
|
|
73
|
+
inputValue: 'Option one',
|
|
71
74
|
renderLabel: 'Choose an option',
|
|
72
75
|
constrain: 'scroll-parent'
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
|
-
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
|
|
76
78
|
filter: (props) => {
|
|
77
79
|
if (props.interaction === 'readonly') return true
|
|
78
80
|
if (props.isRequired) return true
|
|
79
81
|
|
|
80
82
|
return false
|
|
81
83
|
}
|
|
82
|
-
}
|
|
84
|
+
} as StoryConfig<SimpleSelectProps>
|