@instructure/ui-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/Select/index.js +14 -8
- package/lib/Select/index.js +13 -12
- package/package.json +23 -23
- package/src/Select/index.tsx +33 -23
- package/src/Select/props.ts +1 -1
- package/src/index.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Select/SelectLocator.d.ts +9 -9
- package/types/Select/index.d.ts +10 -3
- package/types/Select/index.d.ts.map +1 -1
- package/types/Select/props.d.ts +1 -1
- package/types/Select/props.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
package/es/Select/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import generateComponentTheme from './theme';
|
|
|
48
48
|
import { Group } from './Group';
|
|
49
49
|
import { Option } from './Option';
|
|
50
50
|
import { allowedProps, propTypes } from './props';
|
|
51
|
+
|
|
51
52
|
/**
|
|
52
53
|
---
|
|
53
54
|
category: components
|
|
@@ -55,7 +56,6 @@ tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
|
55
56
|
---
|
|
56
57
|
@tsProps
|
|
57
58
|
**/
|
|
58
|
-
|
|
59
59
|
let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Select extends Component {
|
|
60
60
|
constructor() {
|
|
61
61
|
super(...arguments);
|
|
@@ -120,8 +120,16 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
120
120
|
return this.ref;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
get childrenArray() {
|
|
124
|
+
return Children.toArray(this.props.children);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getGroupChildrenArray(group) {
|
|
128
|
+
return Children.toArray(group.props.children);
|
|
129
|
+
}
|
|
130
|
+
|
|
123
131
|
get focused() {
|
|
124
|
-
return this.ref
|
|
132
|
+
return this.ref ? isActiveElement(this.ref) : false;
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
get id() {
|
|
@@ -140,11 +148,10 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
140
148
|
|
|
141
149
|
get highlightedOptionId() {
|
|
142
150
|
let highlightedOptionId;
|
|
143
|
-
|
|
151
|
+
this.childrenArray.forEach(child => {
|
|
144
152
|
if (matchComponentTypes(child, [Group])) {
|
|
145
153
|
// group found
|
|
146
|
-
|
|
147
|
-
Children.toArray(child.props.children).forEach(option => {
|
|
154
|
+
this.getGroupChildrenArray(child).forEach(option => {
|
|
148
155
|
// check options in group
|
|
149
156
|
if (option.props.isHighlighted) {
|
|
150
157
|
highlightedOptionId = option.props.id;
|
|
@@ -162,11 +169,10 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
162
169
|
|
|
163
170
|
get selectedOptionId() {
|
|
164
171
|
const selectedOptionId = [];
|
|
165
|
-
|
|
172
|
+
this.childrenArray.forEach(child => {
|
|
166
173
|
if (matchComponentTypes(child, [Group])) {
|
|
167
174
|
// group found
|
|
168
|
-
|
|
169
|
-
Children.toArray(child.props.children).forEach(option => {
|
|
175
|
+
this.getGroupChildrenArray(child).forEach(option => {
|
|
170
176
|
// check options in group
|
|
171
177
|
if (option.props.isSelected) {
|
|
172
178
|
selectedOptionId.push(option.props.id);
|
package/lib/Select/index.js
CHANGED
|
@@ -132,8 +132,16 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
132
132
|
return this.ref;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
get childrenArray() {
|
|
136
|
+
return _react.Children.toArray(this.props.children);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getGroupChildrenArray(group) {
|
|
140
|
+
return _react.Children.toArray(group.props.children);
|
|
141
|
+
}
|
|
142
|
+
|
|
135
143
|
get focused() {
|
|
136
|
-
return this.ref
|
|
144
|
+
return this.ref ? (0, _isActiveElement.isActiveElement)(this.ref) : false;
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
get id() {
|
|
@@ -152,13 +160,10 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
152
160
|
|
|
153
161
|
get highlightedOptionId() {
|
|
154
162
|
let highlightedOptionId;
|
|
155
|
-
|
|
156
|
-
_react.Children.toArray(this.props.children).forEach(child => {
|
|
163
|
+
this.childrenArray.forEach(child => {
|
|
157
164
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
158
165
|
// group found
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
_react.Children.toArray(child.props.children).forEach(option => {
|
|
166
|
+
this.getGroupChildrenArray(child).forEach(option => {
|
|
162
167
|
// check options in group
|
|
163
168
|
if (option.props.isHighlighted) {
|
|
164
169
|
highlightedOptionId = option.props.id;
|
|
@@ -171,19 +176,15 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
178
|
});
|
|
174
|
-
|
|
175
179
|
return highlightedOptionId;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
get selectedOptionId() {
|
|
179
183
|
const selectedOptionId = [];
|
|
180
|
-
|
|
181
|
-
_react.Children.toArray(this.props.children).forEach(child => {
|
|
184
|
+
this.childrenArray.forEach(child => {
|
|
182
185
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
183
186
|
// group found
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
_react.Children.toArray(child.props.children).forEach(option => {
|
|
187
|
+
this.getGroupChildrenArray(child).forEach(option => {
|
|
187
188
|
// check options in group
|
|
188
189
|
if (option.props.isSelected) {
|
|
189
190
|
selectedOptionId.push(option.props.id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "8.14.1-snapshot.
|
|
3
|
+
"version": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/ui-babel-preset": "8.14.1-snapshot.
|
|
28
|
-
"@instructure/ui-color-utils": "8.14.1-snapshot.
|
|
29
|
-
"@instructure/ui-test-locator": "8.14.1-snapshot.
|
|
30
|
-
"@instructure/ui-test-utils": "8.14.1-snapshot.
|
|
31
|
-
"@instructure/ui-themes": "8.14.1-snapshot.
|
|
27
|
+
"@instructure/ui-babel-preset": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
28
|
+
"@instructure/ui-color-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
29
|
+
"@instructure/ui-test-locator": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
30
|
+
"@instructure/ui-test-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
31
|
+
"@instructure/ui-themes": "8.14.1-snapshot.68+a2cfa0cd8"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.13.10",
|
|
35
|
-
"@instructure/emotion": "8.14.1-snapshot.
|
|
36
|
-
"@instructure/shared-types": "8.14.1-snapshot.
|
|
37
|
-
"@instructure/ui-dom-utils": "8.14.1-snapshot.
|
|
38
|
-
"@instructure/ui-form-field": "8.14.1-snapshot.
|
|
39
|
-
"@instructure/ui-icons": "8.14.1-snapshot.
|
|
40
|
-
"@instructure/ui-options": "8.14.1-snapshot.
|
|
41
|
-
"@instructure/ui-popover": "8.14.1-snapshot.
|
|
42
|
-
"@instructure/ui-position": "8.14.1-snapshot.
|
|
43
|
-
"@instructure/ui-prop-types": "8.14.1-snapshot.
|
|
44
|
-
"@instructure/ui-react-utils": "8.14.1-snapshot.
|
|
45
|
-
"@instructure/ui-selectable": "8.14.1-snapshot.
|
|
46
|
-
"@instructure/ui-testable": "8.14.1-snapshot.
|
|
47
|
-
"@instructure/ui-text-input": "8.14.1-snapshot.
|
|
48
|
-
"@instructure/ui-utils": "8.14.1-snapshot.
|
|
49
|
-
"@instructure/ui-view": "8.14.1-snapshot.
|
|
50
|
-
"@instructure/uid": "8.14.1-snapshot.
|
|
35
|
+
"@instructure/emotion": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
36
|
+
"@instructure/shared-types": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
37
|
+
"@instructure/ui-dom-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
38
|
+
"@instructure/ui-form-field": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
39
|
+
"@instructure/ui-icons": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
40
|
+
"@instructure/ui-options": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
41
|
+
"@instructure/ui-popover": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
42
|
+
"@instructure/ui-position": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
43
|
+
"@instructure/ui-prop-types": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
44
|
+
"@instructure/ui-react-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
45
|
+
"@instructure/ui-selectable": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
46
|
+
"@instructure/ui-testable": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
47
|
+
"@instructure/ui-text-input": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
48
|
+
"@instructure/ui-utils": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
49
|
+
"@instructure/ui-view": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
50
|
+
"@instructure/uid": "8.14.1-snapshot.68+a2cfa0cd8",
|
|
51
51
|
"prop-types": "^15"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"sideEffects": false,
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a2cfa0cd8bf43d6072f1b352bbd6e43542081be8"
|
|
61
61
|
}
|
package/src/Select/index.tsx
CHANGED
|
@@ -65,13 +65,19 @@ import generateStyle from './styles'
|
|
|
65
65
|
import generateComponentTheme from './theme'
|
|
66
66
|
|
|
67
67
|
import { Group } from './Group'
|
|
68
|
+
import type { SelectGroupProps } from './Group/props'
|
|
68
69
|
import { Option } from './Option'
|
|
70
|
+
import type { SelectOptionProps } from './Option/props'
|
|
69
71
|
|
|
70
72
|
import type { RenderSelectOptionLabel } from './Option/props'
|
|
71
73
|
|
|
72
74
|
import type { SelectProps } from './props'
|
|
73
75
|
import { allowedProps, propTypes } from './props'
|
|
74
76
|
|
|
77
|
+
type GroupChild = React.ComponentElement<SelectGroupProps, Group>
|
|
78
|
+
type OptionChild = React.ComponentElement<SelectOptionProps, Option>
|
|
79
|
+
type SelectChildren = (GroupChild | OptionChild)[]
|
|
80
|
+
|
|
75
81
|
/**
|
|
76
82
|
---
|
|
77
83
|
category: components
|
|
@@ -141,8 +147,16 @@ class Select extends Component<SelectProps> {
|
|
|
141
147
|
return this.ref
|
|
142
148
|
}
|
|
143
149
|
|
|
150
|
+
get childrenArray() {
|
|
151
|
+
return Children.toArray(this.props.children) as SelectChildren
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getGroupChildrenArray(group: GroupChild) {
|
|
155
|
+
return Children.toArray(group.props.children) as OptionChild[]
|
|
156
|
+
}
|
|
157
|
+
|
|
144
158
|
get focused() {
|
|
145
|
-
return this.ref
|
|
159
|
+
return this.ref ? isActiveElement(this.ref) : false
|
|
146
160
|
}
|
|
147
161
|
|
|
148
162
|
get id() {
|
|
@@ -160,12 +174,10 @@ class Select extends Component<SelectProps> {
|
|
|
160
174
|
get highlightedOptionId(): string | undefined {
|
|
161
175
|
let highlightedOptionId: string | undefined
|
|
162
176
|
|
|
163
|
-
|
|
164
|
-
if (matchComponentTypes(child, [Group])) {
|
|
177
|
+
this.childrenArray.forEach((child) => {
|
|
178
|
+
if (matchComponentTypes<GroupChild>(child, [Group])) {
|
|
165
179
|
// group found
|
|
166
|
-
|
|
167
|
-
Children.toArray((child as Group).props.children) as Option[]
|
|
168
|
-
).forEach((option) => {
|
|
180
|
+
this.getGroupChildrenArray(child).forEach((option) => {
|
|
169
181
|
// check options in group
|
|
170
182
|
if (option.props.isHighlighted) {
|
|
171
183
|
highlightedOptionId = option.props.id
|
|
@@ -173,8 +185,8 @@ class Select extends Component<SelectProps> {
|
|
|
173
185
|
})
|
|
174
186
|
} else {
|
|
175
187
|
// ungrouped option found
|
|
176
|
-
if (
|
|
177
|
-
highlightedOptionId =
|
|
188
|
+
if (child.props.isHighlighted) {
|
|
189
|
+
highlightedOptionId = child.props.id
|
|
178
190
|
}
|
|
179
191
|
}
|
|
180
192
|
})
|
|
@@ -185,12 +197,10 @@ class Select extends Component<SelectProps> {
|
|
|
185
197
|
get selectedOptionId() {
|
|
186
198
|
const selectedOptionId: string[] = []
|
|
187
199
|
|
|
188
|
-
|
|
189
|
-
if (matchComponentTypes(child, [Group])) {
|
|
200
|
+
this.childrenArray.forEach((child) => {
|
|
201
|
+
if (matchComponentTypes<GroupChild>(child, [Group])) {
|
|
190
202
|
// group found
|
|
191
|
-
|
|
192
|
-
Children.toArray((child as Group).props.children) as Option[]
|
|
193
|
-
).forEach((option) => {
|
|
203
|
+
this.getGroupChildrenArray(child).forEach((option) => {
|
|
194
204
|
// check options in group
|
|
195
205
|
if (option.props.isSelected) {
|
|
196
206
|
selectedOptionId.push(option.props.id)
|
|
@@ -198,8 +208,8 @@ class Select extends Component<SelectProps> {
|
|
|
198
208
|
})
|
|
199
209
|
} else {
|
|
200
210
|
// ungrouped option found
|
|
201
|
-
if (
|
|
202
|
-
selectedOptionId.push(
|
|
211
|
+
if (child.props.isSelected) {
|
|
212
|
+
selectedOptionId.push(child.props.id)
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
215
|
})
|
|
@@ -331,7 +341,7 @@ class Select extends Component<SelectProps> {
|
|
|
331
341
|
}
|
|
332
342
|
|
|
333
343
|
renderOption(
|
|
334
|
-
option:
|
|
344
|
+
option: OptionChild,
|
|
335
345
|
data: Pick<SelectableRender, 'getOptionProps' | 'getDisabledOptionProps'>
|
|
336
346
|
) {
|
|
337
347
|
const { getOptionProps, getDisabledOptionProps } = data
|
|
@@ -390,7 +400,7 @@ class Select extends Component<SelectProps> {
|
|
|
390
400
|
}
|
|
391
401
|
|
|
392
402
|
renderGroup(
|
|
393
|
-
group:
|
|
403
|
+
group: GroupChild,
|
|
394
404
|
data: Pick<
|
|
395
405
|
SelectableRender,
|
|
396
406
|
'getOptionProps' | 'getDisabledOptionProps'
|
|
@@ -426,7 +436,7 @@ class Select extends Component<SelectProps> {
|
|
|
426
436
|
renderLabel={renderLabel}
|
|
427
437
|
{...omitProps(rest, [...Options.allowedProps, ...Group.allowedProps])}
|
|
428
438
|
>
|
|
429
|
-
{Children.map(children as
|
|
439
|
+
{Children.map(children as OptionChild[], (child) => {
|
|
430
440
|
return this.renderOption(child, {
|
|
431
441
|
getOptionProps,
|
|
432
442
|
getDisabledOptionProps
|
|
@@ -471,21 +481,21 @@ class Select extends Component<SelectProps> {
|
|
|
471
481
|
{...getListProps({ as: 'ul', elementRef: this.handleListRef })}
|
|
472
482
|
>
|
|
473
483
|
{isShowingOptions
|
|
474
|
-
? Children.map(children, (child, index) => {
|
|
484
|
+
? Children.map(children as SelectChildren, (child, index) => {
|
|
475
485
|
if (!child || !matchComponentTypes(child, [Group, Option])) {
|
|
476
486
|
return // ignore invalid children
|
|
477
487
|
}
|
|
478
|
-
if (matchComponentTypes(child, [Option])) {
|
|
488
|
+
if (matchComponentTypes<OptionChild>(child, [Option])) {
|
|
479
489
|
lastWasGroup = false
|
|
480
|
-
return this.renderOption(child
|
|
490
|
+
return this.renderOption(child, {
|
|
481
491
|
getOptionProps,
|
|
482
492
|
getDisabledOptionProps
|
|
483
493
|
})
|
|
484
494
|
}
|
|
485
|
-
if (matchComponentTypes(child, [Group])) {
|
|
495
|
+
if (matchComponentTypes<GroupChild>(child, [Group])) {
|
|
486
496
|
const afterGroup = lastWasGroup
|
|
487
497
|
lastWasGroup = true
|
|
488
|
-
return this.renderGroup(child
|
|
498
|
+
return this.renderGroup(child, {
|
|
489
499
|
getOptionProps,
|
|
490
500
|
getDisabledOptionProps,
|
|
491
501
|
// for rendering separators appropriately
|
package/src/Select/props.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
export { Select } from './Select'
|
|
26
26
|
|
|
27
|
-
export type { SelectProps } from './Select/props'
|
|
27
|
+
export type { SelectProps, SelectOwnProps } from './Select/props'
|
|
28
28
|
export type { SelectGroupProps } from './Select/Group/props'
|
|
29
29
|
export type { SelectOptionProps } from './Select/Option/props'
|