@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,118 +1,118 @@
1
- /**
2
- * @license
3
- * Copyright 2023 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { MenuItemController, } from '@material/web/menu/internal/controllers/menuItemController.js';
7
- /**
8
- * Creates an event fired by a SelectOption to request selection from md-select.
9
- * Typically fired after `selected` changes from `false` to `true`.
10
- */
11
- export function createRequestSelectionEvent() {
12
- return new Event('request-selection', {
13
- bubbles: true,
14
- composed: true,
15
- });
16
- }
17
- /**
18
- * Creates an event fired by a SelectOption to request deselection from
19
- * md-select. Typically fired after `selected` changes from `true` to `false`.
20
- */
21
- export function createRequestDeselectionEvent() {
22
- return new Event('request-deselection', {
23
- bubbles: true,
24
- composed: true,
25
- });
26
- }
27
- /**
28
- * A controller that provides most functionality and md-select compatibility for
29
- * an element that implements the SelectOption interface.
30
- */
31
- export class SelectOptionController {
32
- /**
33
- * The recommended role of the select option.
34
- */
35
- get role() {
36
- return this.menuItemController.role;
37
- }
38
- /**
39
- * The text that is selectable via typeahead. If not set, defaults to the
40
- * innerText of the item slotted into the `"headline"` slot.
41
- */
42
- get typeaheadText() {
43
- return this.menuItemController.typeaheadText;
44
- }
45
- setTypeaheadText(text) {
46
- this.menuItemController.setTypeaheadText(text);
47
- }
48
- /**
49
- * The text that is displayed in the select field when selected. If not set,
50
- * defaults to the textContent of the item slotted into the `"headline"` slot.
51
- */
52
- get displayText() {
53
- if (this.internalDisplayText !== null) {
54
- return this.internalDisplayText;
55
- }
56
- const headlineElements = this.getHeadlineElements();
57
- const textParts = [];
58
- headlineElements.forEach(headlineElement => {
59
- if (headlineElement.textContent && headlineElement.textContent.trim()) {
60
- textParts.push(headlineElement.textContent.trim());
61
- }
62
- });
63
- return textParts.join(' ');
64
- }
65
- setDisplayText(text) {
66
- this.internalDisplayText = text;
67
- }
68
- /**
69
- * @param host The SelectOption in which to attach this controller to.
70
- * @param config The object that configures this controller's behavior.
71
- */
72
- constructor(host, config) {
73
- this.host = host;
74
- this.internalDisplayText = null;
75
- this.lastSelected = this.host.selected;
76
- this.firstUpdate = true;
77
- /**
78
- * Bind this click listener to the interactive element. Handles closing the
79
- * menu.
80
- */
81
- this.onClick = () => {
82
- this.menuItemController.onClick();
83
- };
84
- /**
85
- * Bind this click listener to the interactive element. Handles closing the
86
- * menu.
87
- */
88
- this.onKeydown = (e) => {
89
- this.menuItemController.onKeydown(e);
90
- };
91
- this.menuItemController = new MenuItemController(host, config);
92
- this.getHeadlineElements = config.getHeadlineElements;
93
- host.addController(this);
94
- }
95
- hostUpdate() {
96
- if (this.lastSelected !== this.host.selected) {
97
- this.host.ariaSelected = this.host.selected ? 'true' : 'false';
98
- }
99
- }
100
- hostUpdated() {
101
- // Do not dispatch event on first update / boot-up.
102
- if (this.lastSelected !== this.host.selected && !this.firstUpdate) {
103
- // This section is really useful for when the user sets selected on the
104
- // option programmatically. Most other cases (click and keyboard) are
105
- // handled by md-select because it needs to coordinate the
106
- // single-selection behavior.
107
- if (this.host.selected) {
108
- this.host.dispatchEvent(createRequestSelectionEvent());
109
- }
110
- else {
111
- this.host.dispatchEvent(createRequestDeselectionEvent());
112
- }
113
- }
114
- this.lastSelected = this.host.selected;
115
- this.firstUpdate = false;
116
- }
117
- }
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { MenuItemController, } from '@material/web/menu/internal/controllers/menuItemController.js';
7
+ /**
8
+ * Creates an event fired by a SelectOption to request selection from md-select.
9
+ * Typically fired after `selected` changes from `false` to `true`.
10
+ */
11
+ export function createRequestSelectionEvent() {
12
+ return new Event('request-selection', {
13
+ bubbles: true,
14
+ composed: true,
15
+ });
16
+ }
17
+ /**
18
+ * Creates an event fired by a SelectOption to request deselection from
19
+ * md-select. Typically fired after `selected` changes from `true` to `false`.
20
+ */
21
+ export function createRequestDeselectionEvent() {
22
+ return new Event('request-deselection', {
23
+ bubbles: true,
24
+ composed: true,
25
+ });
26
+ }
27
+ /**
28
+ * A controller that provides most functionality and md-select compatibility for
29
+ * an element that implements the SelectOption interface.
30
+ */
31
+ export class SelectOptionController {
32
+ /**
33
+ * The recommended role of the select option.
34
+ */
35
+ get role() {
36
+ return this.menuItemController.role;
37
+ }
38
+ /**
39
+ * The text that is selectable via typeahead. If not set, defaults to the
40
+ * innerText of the item slotted into the `"headline"` slot.
41
+ */
42
+ get typeaheadText() {
43
+ return this.menuItemController.typeaheadText;
44
+ }
45
+ setTypeaheadText(text) {
46
+ this.menuItemController.setTypeaheadText(text);
47
+ }
48
+ /**
49
+ * The text that is displayed in the select field when selected. If not set,
50
+ * defaults to the textContent of the item slotted into the `"headline"` slot.
51
+ */
52
+ get displayText() {
53
+ if (this.internalDisplayText !== null) {
54
+ return this.internalDisplayText;
55
+ }
56
+ const headlineElements = this.getHeadlineElements();
57
+ const textParts = [];
58
+ headlineElements.forEach(headlineElement => {
59
+ if (headlineElement.textContent && headlineElement.textContent.trim()) {
60
+ textParts.push(headlineElement.textContent.trim());
61
+ }
62
+ });
63
+ return textParts.join(' ');
64
+ }
65
+ setDisplayText(text) {
66
+ this.internalDisplayText = text;
67
+ }
68
+ /**
69
+ * @param host The SelectOption in which to attach this controller to.
70
+ * @param config The object that configures this controller's behavior.
71
+ */
72
+ constructor(host, config) {
73
+ this.host = host;
74
+ this.internalDisplayText = null;
75
+ this.lastSelected = this.host.selected;
76
+ this.firstUpdate = true;
77
+ /**
78
+ * Bind this click listener to the interactive element. Handles closing the
79
+ * menu.
80
+ */
81
+ this.onClick = () => {
82
+ this.menuItemController.onClick();
83
+ };
84
+ /**
85
+ * Bind this click listener to the interactive element. Handles closing the
86
+ * menu.
87
+ */
88
+ this.onKeydown = (e) => {
89
+ this.menuItemController.onKeydown(e);
90
+ };
91
+ this.menuItemController = new MenuItemController(host, config);
92
+ this.getHeadlineElements = config.getHeadlineElements;
93
+ host.addController(this);
94
+ }
95
+ hostUpdate() {
96
+ if (this.lastSelected !== this.host.selected) {
97
+ this.host.ariaSelected = this.host.selected ? 'true' : 'false';
98
+ }
99
+ }
100
+ hostUpdated() {
101
+ // Do not dispatch event on first update / boot-up.
102
+ if (this.lastSelected !== this.host.selected && !this.firstUpdate) {
103
+ // This section is really useful for when the user sets selected on the
104
+ // option programmatically. Most other cases (click and keyboard) are
105
+ // handled by md-select because it needs to coordinate the
106
+ // single-selection behavior.
107
+ if (this.host.selected) {
108
+ this.host.dispatchEvent(createRequestSelectionEvent());
109
+ }
110
+ else {
111
+ this.host.dispatchEvent(createRequestDeselectionEvent());
112
+ }
113
+ }
114
+ this.lastSelected = this.host.selected;
115
+ this.firstUpdate = false;
116
+ }
117
+ }
118
118
  //# sourceMappingURL=selectOptionController.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent ix-select following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "interxion",
6
- "version": "1.1.3",
6
+ "version": "1.1.4",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -108,5 +108,5 @@
108
108
  "README.md",
109
109
  "LICENSE"
110
110
  ],
111
- "gitHead": "d05f7852e15c67ec82d2b44f3d730398f25c55c4"
111
+ "gitHead": "b9d5ef1127e1f10cd74d54fcdc03825b4476b403"
112
112
  }