@digital-realty/ix-select 1.1.3 → 1.1.4

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.
@@ -1,72 +1,72 @@
1
- /**
2
- * @license
3
- * Copyright 2023 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { __decorate } from "tslib";
7
- import '@material/web/ripple/ripple.js';
8
- import '@material/web/focus/md-focus-ring.js';
9
- import '@material/web/labs/item/item.js';
10
- import { html, LitElement, nothing } from 'lit';
11
- import { property, query, queryAssignedElements, queryAssignedNodes, } from 'lit/decorators.js';
12
- import { classMap } from 'lit/directives/class-map.js';
13
- import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
14
- import { SelectOptionController, } from './selectOptionController.js';
15
- /**
16
- * @fires close-menu Closes the encapsulating menu on
17
- * @fires request-selection Requests the parent md-select to select this element
18
- * (and deselect others if single-selection) when `selected` changed to `true`.
19
- * @fires request-deselection Requests the parent md-select to deselect this
20
- * element when `selected` changed to `false`.
21
- */
22
- export class IxSelectOption extends LitElement {
23
- constructor() {
24
- super(...arguments);
25
- /**
26
- * Disables the item and makes it non-selectable and non-interactive.
27
- */
28
- this.disabled = false;
29
- /**
30
- * READONLY: self-identifies as a menu item and sets its identifying attribute
31
- */
32
- this.isMenuItem = true;
33
- /**
34
- * Sets the item in the selected visual state when a submenu is opened.
35
- */
36
- this.selected = false;
37
- /**
38
- * Form value of the option.
39
- */
40
- this.value = '';
41
- this.type = 'option';
42
- this.selectOptionController = new SelectOptionController(this, {
43
- getHeadlineElements: () => this.headlineElements,
44
- getSupportingTextElements: () => this.supportingTextElements,
45
- getDefaultElements: () => this.defaultElements,
46
- getInteractiveElement: () => this.listItemRoot,
47
- });
48
- }
49
- /**
50
- * The text that is selectable via typeahead. If not set, defaults to the
51
- * innerText of the item slotted into the `"headline"` slot.
52
- */
53
- get typeaheadText() {
54
- return this.selectOptionController.typeaheadText;
55
- }
56
- set typeaheadText(text) {
57
- this.selectOptionController.setTypeaheadText(text);
58
- }
59
- /**
60
- * The text that is displayed in the select field when selected. If not set,
61
- * defaults to the textContent of the item slotted into the `"headline"` slot.
62
- */
63
- get displayText() {
64
- return this.selectOptionController.displayText;
65
- }
66
- set displayText(text) {
67
- this.selectOptionController.setDisplayText(text);
68
- }
69
- render() {
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { __decorate } from "tslib";
7
+ import '@material/web/ripple/ripple.js';
8
+ import '@material/web/focus/md-focus-ring.js';
9
+ import '@material/web/labs/item/item.js';
10
+ import { html, LitElement, nothing } from 'lit';
11
+ import { property, query, queryAssignedElements, queryAssignedNodes, } from 'lit/decorators.js';
12
+ import { classMap } from 'lit/directives/class-map.js';
13
+ import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
14
+ import { SelectOptionController, } from './selectOptionController.js';
15
+ /**
16
+ * @fires close-menu Closes the encapsulating menu on
17
+ * @fires request-selection Requests the parent md-select to select this element
18
+ * (and deselect others if single-selection) when `selected` changed to `true`.
19
+ * @fires request-deselection Requests the parent md-select to deselect this
20
+ * element when `selected` changed to `false`.
21
+ */
22
+ export class IxSelectOption extends LitElement {
23
+ constructor() {
24
+ super(...arguments);
25
+ /**
26
+ * Disables the item and makes it non-selectable and non-interactive.
27
+ */
28
+ this.disabled = false;
29
+ /**
30
+ * READONLY: self-identifies as a menu item and sets its identifying attribute
31
+ */
32
+ this.isMenuItem = true;
33
+ /**
34
+ * Sets the item in the selected visual state when a submenu is opened.
35
+ */
36
+ this.selected = false;
37
+ /**
38
+ * Form value of the option.
39
+ */
40
+ this.value = '';
41
+ this.type = 'option';
42
+ this.selectOptionController = new SelectOptionController(this, {
43
+ getHeadlineElements: () => this.headlineElements,
44
+ getSupportingTextElements: () => this.supportingTextElements,
45
+ getDefaultElements: () => this.defaultElements,
46
+ getInteractiveElement: () => this.listItemRoot,
47
+ });
48
+ }
49
+ /**
50
+ * The text that is selectable via typeahead. If not set, defaults to the
51
+ * innerText of the item slotted into the `"headline"` slot.
52
+ */
53
+ get typeaheadText() {
54
+ return this.selectOptionController.typeaheadText;
55
+ }
56
+ set typeaheadText(text) {
57
+ this.selectOptionController.setTypeaheadText(text);
58
+ }
59
+ /**
60
+ * The text that is displayed in the select field when selected. If not set,
61
+ * defaults to the textContent of the item slotted into the `"headline"` slot.
62
+ */
63
+ get displayText() {
64
+ return this.selectOptionController.displayText;
65
+ }
66
+ set displayText(text) {
67
+ this.selectOptionController.setDisplayText(text);
68
+ }
69
+ render() {
70
70
  return this.renderListItem(html `
71
71
  <md-item>
72
72
  <div slot="container">
@@ -76,14 +76,14 @@ export class IxSelectOption extends LitElement {
76
76
  <slot name="end" slot="end"></slot>
77
77
  ${this.renderBody()}
78
78
  </md-item>
79
- `);
80
- }
81
- /**
82
- * Renders the root list item.
83
- *
84
- * @param content the child content of the list item.
85
- */
86
- renderListItem(content) {
79
+ `);
80
+ }
81
+ /**
82
+ * Renders the root list item.
83
+ *
84
+ * @param content the child content of the list item.
85
+ */
86
+ renderListItem(content) {
87
87
  return html `
88
88
  <li
89
89
  id="item"
@@ -100,43 +100,43 @@ export class IxSelectOption extends LitElement {
100
100
  >
101
101
  ${content}
102
102
  </li>
103
- `;
104
- }
105
- /**
106
- * Handles rendering of the ripple element.
107
- */
108
- renderRipple() {
103
+ `;
104
+ }
105
+ /**
106
+ * Handles rendering of the ripple element.
107
+ */
108
+ renderRipple() {
109
109
  return html ` <md-ripple
110
110
  part="ripple"
111
111
  for="item"
112
112
  ?disabled=${this.disabled}
113
- ></md-ripple>`;
114
- }
115
- /**
116
- * Handles rendering of the focus ring.
117
- */
118
- // eslint-disable-next-line class-methods-use-this
119
- renderFocusRing() {
113
+ ></md-ripple>`;
114
+ }
115
+ /**
116
+ * Handles rendering of the focus ring.
117
+ */
118
+ // eslint-disable-next-line class-methods-use-this
119
+ renderFocusRing() {
120
120
  return html ` <md-focus-ring
121
121
  part="focus-ring"
122
122
  for="item"
123
123
  inward
124
- ></md-focus-ring>`;
125
- }
126
- /**
127
- * Classes applied to the list item root.
128
- */
129
- getRenderClasses() {
130
- return {
131
- disabled: this.disabled,
132
- selected: this.selected,
133
- };
134
- }
135
- /**
136
- * Handles rendering the headline and supporting text.
137
- */
138
- // eslint-disable-next-line class-methods-use-this
139
- renderBody() {
124
+ ></md-focus-ring>`;
125
+ }
126
+ /**
127
+ * Classes applied to the list item root.
128
+ */
129
+ getRenderClasses() {
130
+ return {
131
+ disabled: this.disabled,
132
+ selected: this.selected,
133
+ };
134
+ }
135
+ /**
136
+ * Handles rendering the headline and supporting text.
137
+ */
138
+ // eslint-disable-next-line class-methods-use-this
139
+ renderBody() {
140
140
  return html `
141
141
  <slot></slot>
142
142
  <slot name="overline" slot="overline"></slot>
@@ -146,51 +146,51 @@ export class IxSelectOption extends LitElement {
146
146
  name="trailing-supporting-text"
147
147
  slot="trailing-supporting-text"
148
148
  ></slot>
149
- `;
150
- }
151
- focus() {
152
- var _a;
153
- // TODO(b/300334509): needed for some cases where delegatesFocus doesn't
154
- // work programmatically like in FF and select-option
155
- (_a = this.listItemRoot) === null || _a === void 0 ? void 0 : _a.focus();
156
- }
157
- }
158
- (() => {
159
- requestUpdateOnAriaChange(IxSelectOption);
160
- })();
161
- /** @nocollapse */
162
- IxSelectOption.shadowRootOptions = {
163
- ...LitElement.shadowRootOptions,
164
- delegatesFocus: true,
165
- };
166
- __decorate([
167
- property({ type: Boolean, reflect: true })
168
- ], IxSelectOption.prototype, "disabled", void 0);
169
- __decorate([
170
- property({ type: Boolean, attribute: 'md-menu-item', reflect: true })
171
- ], IxSelectOption.prototype, "isMenuItem", void 0);
172
- __decorate([
173
- property({ type: Boolean })
174
- ], IxSelectOption.prototype, "selected", void 0);
175
- __decorate([
176
- property()
177
- ], IxSelectOption.prototype, "value", void 0);
178
- __decorate([
179
- query('.list-item')
180
- ], IxSelectOption.prototype, "listItemRoot", void 0);
181
- __decorate([
182
- queryAssignedElements({ slot: 'headline' })
183
- ], IxSelectOption.prototype, "headlineElements", void 0);
184
- __decorate([
185
- queryAssignedElements({ slot: 'supporting-text' })
186
- ], IxSelectOption.prototype, "supportingTextElements", void 0);
187
- __decorate([
188
- queryAssignedNodes({ slot: '' })
189
- ], IxSelectOption.prototype, "defaultElements", void 0);
190
- __decorate([
191
- property({ attribute: 'typeahead-text' })
192
- ], IxSelectOption.prototype, "typeaheadText", null);
193
- __decorate([
194
- property({ attribute: 'display-text' })
195
- ], IxSelectOption.prototype, "displayText", null);
149
+ `;
150
+ }
151
+ focus() {
152
+ var _a;
153
+ // TODO(b/300334509): needed for some cases where delegatesFocus doesn't
154
+ // work programmatically like in FF and select-option
155
+ (_a = this.listItemRoot) === null || _a === void 0 ? void 0 : _a.focus();
156
+ }
157
+ }
158
+ (() => {
159
+ requestUpdateOnAriaChange(IxSelectOption);
160
+ })();
161
+ /** @nocollapse */
162
+ IxSelectOption.shadowRootOptions = {
163
+ ...LitElement.shadowRootOptions,
164
+ delegatesFocus: true,
165
+ };
166
+ __decorate([
167
+ property({ type: Boolean, reflect: true })
168
+ ], IxSelectOption.prototype, "disabled", void 0);
169
+ __decorate([
170
+ property({ type: Boolean, attribute: 'md-menu-item', reflect: true })
171
+ ], IxSelectOption.prototype, "isMenuItem", void 0);
172
+ __decorate([
173
+ property({ type: Boolean })
174
+ ], IxSelectOption.prototype, "selected", void 0);
175
+ __decorate([
176
+ property()
177
+ ], IxSelectOption.prototype, "value", void 0);
178
+ __decorate([
179
+ query('.list-item')
180
+ ], IxSelectOption.prototype, "listItemRoot", void 0);
181
+ __decorate([
182
+ queryAssignedElements({ slot: 'headline' })
183
+ ], IxSelectOption.prototype, "headlineElements", void 0);
184
+ __decorate([
185
+ queryAssignedElements({ slot: 'supporting-text' })
186
+ ], IxSelectOption.prototype, "supportingTextElements", void 0);
187
+ __decorate([
188
+ queryAssignedNodes({ slot: '' })
189
+ ], IxSelectOption.prototype, "defaultElements", void 0);
190
+ __decorate([
191
+ property({ attribute: 'typeahead-text' })
192
+ ], IxSelectOption.prototype, "typeaheadText", null);
193
+ __decorate([
194
+ property({ attribute: 'display-text' })
195
+ ], IxSelectOption.prototype, "displayText", null);
196
196
  //# sourceMappingURL=IxSelectOption.js.map
@@ -1,4 +1,4 @@
1
- import { IxSelectOption } from './IxSelectOption.js';
2
- export declare class IxSelectOptionStyled extends IxSelectOption {
3
- static styles: import("lit").CSSResult[];
4
- }
1
+ import { IxSelectOption } from './IxSelectOption.js';
2
+ export declare class IxSelectOptionStyled extends IxSelectOption {
3
+ static styles: import("lit").CSSResult[];
4
+ }
@@ -1,7 +1,7 @@
1
- import { styles } from '@material/web/menu/internal/menuitem/menu-item-styles.css.js';
2
- import { IxSelectOption } from './IxSelectOption.js';
3
- export class IxSelectOptionStyled extends IxSelectOption {
4
- }
5
- IxSelectOptionStyled.styles = [styles];
6
- window.customElements.define('ix-select-option', IxSelectOptionStyled);
1
+ import { styles } from '@material/web/menu/internal/menuitem/menu-item-styles.css.js';
2
+ import { IxSelectOption } from './IxSelectOption.js';
3
+ export class IxSelectOptionStyled extends IxSelectOption {
4
+ }
5
+ IxSelectOptionStyled.styles = [styles];
6
+ window.customElements.define('ix-select-option', IxSelectOptionStyled);
7
7
  //# sourceMappingURL=ix-select-option.js.map
@@ -1,93 +1,93 @@
1
- /**
2
- * @license
3
- * Copyright 2023 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { ReactiveController, ReactiveControllerHost } from 'lit';
7
- import { MenuItem, MenuItemControllerConfig } from '@material/web/menu/internal/controllers/menuItemController.js';
8
- /**
9
- * The interface specific to a Select Option
10
- */
11
- interface SelectOptionSelf {
12
- /**
13
- * The form value associated with the Select Option. (Note: the visual portion
14
- * of the SelectOption is the headline defined in ListItem)
15
- */
16
- value: string;
17
- /**
18
- * Whether or not the SelectOption is selected.
19
- */
20
- selected: boolean;
21
- /**
22
- * The text to display in the select when selected. Defaults to the
23
- * textContent of the Element slotted into the headline.
24
- */
25
- displayText: string;
26
- }
27
- /**
28
- * The interface to implement for a select option. Additionally, the element
29
- * must have `md-list-item` and `md-menu-item` attributes on the host.
30
- */
31
- export type SelectOption = SelectOptionSelf & MenuItem;
32
- /**
33
- * Creates an event fired by a SelectOption to request selection from md-select.
34
- * Typically fired after `selected` changes from `false` to `true`.
35
- */
36
- export declare function createRequestSelectionEvent(): Event;
37
- /**
38
- * Creates an event fired by a SelectOption to request deselection from
39
- * md-select. Typically fired after `selected` changes from `true` to `false`.
40
- */
41
- export declare function createRequestDeselectionEvent(): Event;
42
- /**
43
- * The options used to inialize SelectOptionController.
44
- */
45
- export interface SelectOptionConfig extends MenuItemControllerConfig {
46
- getInteractiveElement(): HTMLElement | null;
47
- }
48
- /**
49
- * A controller that provides most functionality and md-select compatibility for
50
- * an element that implements the SelectOption interface.
51
- */
52
- export declare class SelectOptionController implements ReactiveController {
53
- private readonly host;
54
- private readonly menuItemController;
55
- private readonly getHeadlineElements;
56
- private internalDisplayText;
57
- private lastSelected;
58
- private firstUpdate;
59
- /**
60
- * The recommended role of the select option.
61
- */
62
- get role(): "menuitem" | "option";
63
- /**
64
- * The text that is selectable via typeahead. If not set, defaults to the
65
- * innerText of the item slotted into the `"headline"` slot.
66
- */
67
- get typeaheadText(): string;
68
- setTypeaheadText(text: string): void;
69
- /**
70
- * The text that is displayed in the select field when selected. If not set,
71
- * defaults to the textContent of the item slotted into the `"headline"` slot.
72
- */
73
- get displayText(): string;
74
- setDisplayText(text: string): void;
75
- /**
76
- * @param host The SelectOption in which to attach this controller to.
77
- * @param config The object that configures this controller's behavior.
78
- */
79
- constructor(host: ReactiveControllerHost & SelectOption, config: SelectOptionConfig);
80
- hostUpdate(): void;
81
- hostUpdated(): void;
82
- /**
83
- * Bind this click listener to the interactive element. Handles closing the
84
- * menu.
85
- */
86
- onClick: () => void;
87
- /**
88
- * Bind this click listener to the interactive element. Handles closing the
89
- * menu.
90
- */
91
- onKeydown: (e: KeyboardEvent) => void;
92
- }
93
- export {};
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
7
+ import { MenuItem, MenuItemControllerConfig } from '@material/web/menu/internal/controllers/menuItemController.js';
8
+ /**
9
+ * The interface specific to a Select Option
10
+ */
11
+ interface SelectOptionSelf {
12
+ /**
13
+ * The form value associated with the Select Option. (Note: the visual portion
14
+ * of the SelectOption is the headline defined in ListItem)
15
+ */
16
+ value: string;
17
+ /**
18
+ * Whether or not the SelectOption is selected.
19
+ */
20
+ selected: boolean;
21
+ /**
22
+ * The text to display in the select when selected. Defaults to the
23
+ * textContent of the Element slotted into the headline.
24
+ */
25
+ displayText: string;
26
+ }
27
+ /**
28
+ * The interface to implement for a select option. Additionally, the element
29
+ * must have `md-list-item` and `md-menu-item` attributes on the host.
30
+ */
31
+ export type SelectOption = SelectOptionSelf & MenuItem;
32
+ /**
33
+ * Creates an event fired by a SelectOption to request selection from md-select.
34
+ * Typically fired after `selected` changes from `false` to `true`.
35
+ */
36
+ export declare function createRequestSelectionEvent(): Event;
37
+ /**
38
+ * Creates an event fired by a SelectOption to request deselection from
39
+ * md-select. Typically fired after `selected` changes from `true` to `false`.
40
+ */
41
+ export declare function createRequestDeselectionEvent(): Event;
42
+ /**
43
+ * The options used to inialize SelectOptionController.
44
+ */
45
+ export interface SelectOptionConfig extends MenuItemControllerConfig {
46
+ getInteractiveElement(): HTMLElement | null;
47
+ }
48
+ /**
49
+ * A controller that provides most functionality and md-select compatibility for
50
+ * an element that implements the SelectOption interface.
51
+ */
52
+ export declare class SelectOptionController implements ReactiveController {
53
+ private readonly host;
54
+ private readonly menuItemController;
55
+ private readonly getHeadlineElements;
56
+ private internalDisplayText;
57
+ private lastSelected;
58
+ private firstUpdate;
59
+ /**
60
+ * The recommended role of the select option.
61
+ */
62
+ get role(): "menuitem" | "option";
63
+ /**
64
+ * The text that is selectable via typeahead. If not set, defaults to the
65
+ * innerText of the item slotted into the `"headline"` slot.
66
+ */
67
+ get typeaheadText(): string;
68
+ setTypeaheadText(text: string): void;
69
+ /**
70
+ * The text that is displayed in the select field when selected. If not set,
71
+ * defaults to the textContent of the item slotted into the `"headline"` slot.
72
+ */
73
+ get displayText(): string;
74
+ setDisplayText(text: string): void;
75
+ /**
76
+ * @param host The SelectOption in which to attach this controller to.
77
+ * @param config The object that configures this controller's behavior.
78
+ */
79
+ constructor(host: ReactiveControllerHost & SelectOption, config: SelectOptionConfig);
80
+ hostUpdate(): void;
81
+ hostUpdated(): void;
82
+ /**
83
+ * Bind this click listener to the interactive element. Handles closing the
84
+ * menu.
85
+ */
86
+ onClick: () => void;
87
+ /**
88
+ * Bind this click listener to the interactive element. Handles closing the
89
+ * menu.
90
+ */
91
+ onKeydown: (e: KeyboardEvent) => void;
92
+ }
93
+ export {};