Skip to content

Commit edb3559

Browse files
fix(select): expose SelectOption interface
PiperOrigin-RevId: 592022961
1 parent 18bdabe commit edb3559

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed

select/internal/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ import {
3939
} from '../../menu/internal/controllers/shared.js';
4040
import {TYPEAHEAD_RECORD} from '../../menu/internal/controllers/typeaheadController.js';
4141
import {DEFAULT_TYPEAHEAD_BUFFER_TIME, Menu} from '../../menu/internal/menu.js';
42+
import {SelectOption} from './selectoption/select-option.js';
4243
import {
4344
createRequestDeselectionEvent,
4445
createRequestSelectionEvent,
45-
SelectOption,
4646
} from './selectoption/selectOptionController.js';
4747
import {getSelectedItems, SelectOptionRecord} from './shared.js';
4848

select/internal/selectoption/select-option.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,35 @@ import {ClassInfo, classMap} from 'lit/directives/class-map.js';
1919

2020
import {ARIAMixinStrict} from '../../../internal/aria/aria.js';
2121
import {requestUpdateOnAriaChange} from '../../../internal/aria/delegate.js';
22+
import {MenuItem} from '../../../menu/internal/controllers/menuItemController.js';
2223

23-
import {SelectOption, SelectOptionController} from './selectOptionController.js';
24+
import {SelectOptionController} from './selectOptionController.js';
25+
26+
/**
27+
* The interface specific to a Select Option
28+
*/
29+
interface SelectOptionSelf {
30+
/**
31+
* The form value associated with the Select Option. (Note: the visual portion
32+
* of the SelectOption is the headline defined in ListItem)
33+
*/
34+
value: string;
35+
/**
36+
* Whether or not the SelectOption is selected.
37+
*/
38+
selected: boolean;
39+
/**
40+
* The text to display in the select when selected. Defaults to the
41+
* textContent of the Element slotted into the headline.
42+
*/
43+
displayText: string;
44+
}
45+
46+
/**
47+
* The interface to implement for a select option. Additionally, the element
48+
* must have `md-list-item` and `md-menu-item` attributes on the host.
49+
*/
50+
export type SelectOption = SelectOptionSelf & MenuItem;
2451

2552
/**
2653
* @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}

select/internal/selectoption/selectOptionController.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,10 @@
77
import {ReactiveController, ReactiveControllerHost} from 'lit';
88

99
import {
10-
MenuItem,
1110
MenuItemController,
1211
MenuItemControllerConfig,
1312
} from '../../../menu/internal/controllers/menuItemController.js';
14-
15-
/**
16-
* The interface specific to a Select Option
17-
*/
18-
interface SelectOptionSelf {
19-
/**
20-
* The form value associated with the Select Option. (Note: the visual portion
21-
* of the SelectOption is the headline defined in ListItem)
22-
*/
23-
value: string;
24-
/**
25-
* Whether or not the SelectOption is selected.
26-
*/
27-
selected: boolean;
28-
/**
29-
* The text to display in the select when selected. Defaults to the
30-
* textContent of the Element slotted into the headline.
31-
*/
32-
displayText: string;
33-
}
34-
35-
/**
36-
* The interface to implement for a select option. Additionally, the element
37-
* must have `md-list-item` and `md-menu-item` attributes on the host.
38-
*/
39-
export type SelectOption = SelectOptionSelf & MenuItem;
13+
import {SelectOption} from './select-option.js';
4014

4115
/**
4216
* Creates an event fired by a SelectOption to request selection from md-select.

select/internal/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {SelectOption} from './selectoption/selectOptionController.js';
7+
import {SelectOption} from './selectoption/select-option.js';
88

99
/**
1010
* A type that describes a SelectOption and its index.

select/select-option.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {styles} from '../menu/internal/menuitem/menu-item-styles.css.js';
1111
// TODO(b/236285090): update with HCM best practices
1212
import {SelectOptionEl} from './internal/selectoption/select-option.js';
1313

14+
export {SelectOption} from './internal/selectoption/select-option.js';
15+
1416
declare global {
1517
interface HTMLElementTagNameMap {
1618
'md-select-option': MdSelectOption;

0 commit comments

Comments
 (0)