@limetech/lime-elements 33.14.0-next.10 → 33.14.0-next.14

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.
Files changed (31) hide show
  1. package/dist/cjs/limel-list_3.cjs.entry.js +355 -362
  2. package/dist/cjs/limel-tooltip-content.cjs.entry.js +5 -2
  3. package/dist/cjs/limel-tooltip.cjs.entry.js +1 -1
  4. package/dist/collection/components/header/header.js +0 -1
  5. package/dist/collection/components/list/list-renderer.js +158 -160
  6. package/dist/collection/components/list/list.js +115 -117
  7. package/dist/collection/components/menu/menu.js +1 -1
  8. package/dist/collection/components/menu-surface/menu-surface.js +84 -87
  9. package/dist/collection/components/popover/popover.js +0 -1
  10. package/dist/collection/components/tooltip/tooltip-content.css +25 -13
  11. package/dist/collection/components/tooltip/tooltip-content.js +4 -3
  12. package/dist/collection/components/tooltip/tooltip.css +0 -6
  13. package/dist/collection/components/tooltip/tooltip.js +31 -5
  14. package/dist/esm/limel-list_3.entry.js +355 -362
  15. package/dist/esm/limel-tooltip-content.entry.js +5 -2
  16. package/dist/esm/limel-tooltip.entry.js +1 -1
  17. package/dist/lime-elements/lime-elements.esm.js +1 -1
  18. package/dist/lime-elements/p-8e40ab4c.entry.js +177 -0
  19. package/dist/lime-elements/{p-b0b18dfc.entry.js → p-8e4e13b3.entry.js} +1 -1
  20. package/dist/lime-elements/p-aeada929.entry.js +1 -0
  21. package/dist/types/components/header/header.d.ts +0 -1
  22. package/dist/types/components/list/list-renderer.d.ts +0 -1
  23. package/dist/types/components/list/list.d.ts +0 -1
  24. package/dist/types/components/menu/menu.types.d.ts +1 -1
  25. package/dist/types/components/menu-surface/menu-surface.d.ts +0 -1
  26. package/dist/types/components/popover/popover.d.ts +0 -1
  27. package/dist/types/components/tooltip/tooltip-content.d.ts +1 -1
  28. package/dist/types/components/tooltip/tooltip.d.ts +31 -5
  29. package/package.json +2 -1
  30. package/dist/lime-elements/p-a6a7dd00.entry.js +0 -1
  31. package/dist/lime-elements/p-e078c459.entry.js +0 -177
@@ -4,14 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-153dc912.js');
6
6
 
7
- const tooltipContentCss = ".tooltip-content{display:flex;flex-direction:row;color:rgb(var(--color-gray-default));border-radius:0.5rem;width:auto;display:flex;padding:0.75rem;transition:opacity 150ms ease-out;margin-top:0.3rem;background-color:rgb(var(--color-gray-darker))}.tooltip-content .tooltip{color:rgb(var(--color-gray-lighter))}.tooltip-content .helperLabel{padding:0 0 0 1rem}.tooltip-content .helperLabel:empty{display:none}";
7
+ const tooltipContentCss = ":host{animation:display-tooltip 0.2s ease;display:flex;flex-direction:row;border-radius:0.25rem;padding:0.25rem 0.5rem;font-size:0.875rem;background-color:rgb(var(--contrast-1300));box-shadow:var(--shadow-depth-16)}.label{color:rgb(var(--contrast-200))}.helper-label{color:rgb(var(--contrast-800));padding:0 0 0 1rem}.helper-label:empty{display:none}@keyframes display-tooltip{0%{opacity:0;transform:translate3d(0, 0, 0) scale(0.94)}100%{opacity:1;transform:translate3d(0, 0, 0) scale(1)}}";
8
8
 
9
9
  const TooltipContent = class {
10
10
  constructor(hostRef) {
11
11
  index.registerInstance(this, hostRef);
12
12
  }
13
13
  render() {
14
- return (index.h("div", { class: "tooltip-content" }, index.h("div", { class: "tooltip" }, this.label), index.h("div", { class: "helperLabel" }, this.helperLabel)));
14
+ return [
15
+ index.h("div", { class: "label" }, this.label),
16
+ index.h("div", { class: "helper-label" }, this.helperLabel),
17
+ ];
15
18
  }
16
19
  };
17
20
  TooltipContent.style = tooltipContentCss;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-153dc912.js');
6
6
  const randomString = require('./random-string-4c3b7f1c.js');
7
7
 
8
- const tooltipCss = ".trigger-anchor{display:inline-block;position:relative}.tooltip-container{color:#f1f1f1;background-color:#232324}";
8
+ const tooltipCss = ".trigger-anchor{position:relative}";
9
9
 
10
10
  const Tooltip = class {
11
11
  constructor(hostRef) {
@@ -43,7 +43,6 @@ import { Component, h, Prop } from '@stencil/core';
43
43
  * @exampleComponent limel-example-header-responsive
44
44
  * @exampleComponent limel-example-header-narrow
45
45
  * @slot - Content (actions) to be put inside the far right surface of the header
46
- * @private
47
46
  */
48
47
  export class Header {
49
48
  render() {
@@ -7,8 +7,164 @@ export class ListRenderer {
7
7
  isOpen: true,
8
8
  badgeIcons: false,
9
9
  };
10
- this.renderListItem = this.renderListItem.bind(this);
11
- this.renderDivider = this.renderDivider.bind(this);
10
+ /**
11
+ * Determine which ListItem should have the `tab-index` attribute set,
12
+ * and return the index at which that ListItem is located in `items`.
13
+ * Returns `undefined` if no item should have the attribute set.
14
+ * See https://github.com/material-components/material-components-web/tree/e66a43a75fef4f9179e24856649518e15e279a04/packages/mdc-list#accessibility
15
+ *
16
+ * @param {Array<ListItem | ListSeparator | MenuItems>} items the items of the list, including any `ListSeparator`:s
17
+ * @returns {number} the index as per the description
18
+ */
19
+ this.getIndexForWhichToApplyTabIndex = (items) => {
20
+ let result;
21
+ for (let i = 0, max = items.length; i < max; i += 1) {
22
+ if ('separator' in items[i]) {
23
+ // Ignore ListSeparator
24
+ }
25
+ else {
26
+ const item = items[i];
27
+ if (item.selected) {
28
+ result = i;
29
+ break;
30
+ }
31
+ if (result === undefined && !item.disabled) {
32
+ result = i;
33
+ // Do NOT break, as any later item with
34
+ // `selected=true` should get the tab-index instead!
35
+ }
36
+ }
37
+ }
38
+ return result;
39
+ };
40
+ /**
41
+ * Render a single list item
42
+ *
43
+ * @param {ListItem | ListSeparator | MenuItems} item the item to render
44
+ * @param {number} index the index the item had in the `items` array
45
+ * @returns {HTMLElement} the list item
46
+ */
47
+ this.renderListItem = (item, index) => {
48
+ if ('separator' in item) {
49
+ return h("li", { class: "mdc-deprecated-list-divider", role: "separator" });
50
+ }
51
+ if (['radio', 'checkbox'].includes(this.config.type)) {
52
+ return this.renderVariantListItem(this.config, item, index);
53
+ }
54
+ const classNames = {
55
+ 'mdc-deprecated-list-item': true,
56
+ 'mdc-deprecated-list-item--disabled': item.disabled,
57
+ 'mdc-deprecated-list-item--selected': item.selected,
58
+ };
59
+ const attributes = {};
60
+ if (index === this.applyTabIndexToItemAtIndex) {
61
+ attributes.tabindex = '0';
62
+ }
63
+ return (h("li", Object.assign({ class: classNames, role: this.config.type === 'menu' ? 'menuitem' : '', "aria-disabled": item.disabled ? 'true' : 'false', "aria-selected": item.selected ? 'true' : 'false', "data-index": index }, attributes),
64
+ item.icon ? this.renderIcon(this.config, item) : null,
65
+ this.renderText(item),
66
+ this.twoLines && this.avatarList ? this.renderDivider() : null,
67
+ this.renderActionMenu(item.actions)));
68
+ };
69
+ /**
70
+ * Render the text of the list item
71
+ *
72
+ * @param {ListItem | MenuItem} item the list item
73
+ * @returns {HTMLElement | string} the text for the list item
74
+ */
75
+ this.renderText = (item) => {
76
+ if (this.isSimpleItem(item)) {
77
+ return (h("span", { class: "mdc-deprecated-list-item__text" }, item.text));
78
+ }
79
+ return (h("div", { class: "mdc-deprecated-list-item__text" },
80
+ h("div", { class: "mdc-deprecated-list-item__primary-command-text" },
81
+ h("div", { class: "mdc-deprecated-list-item__primary-text" }, item.text),
82
+ this.renderCommandText(item)),
83
+ h("div", { class: "mdc-deprecated-list-item__secondary-text" }, item.secondaryText)));
84
+ };
85
+ this.renderCommandText = (item) => {
86
+ if (!('commandText' in item)) {
87
+ return;
88
+ }
89
+ return (h("div", { class: "mdc-deprecated-list-item__command-text" }, item.commandText));
90
+ };
91
+ this.isSimpleItem = (item) => {
92
+ if ('commandText' in item) {
93
+ return false;
94
+ }
95
+ if ('secondaryText' in item) {
96
+ return false;
97
+ }
98
+ return true;
99
+ };
100
+ /**
101
+ * Render an icon for a list item
102
+ *
103
+ * @param {ListRendererConfig} config the config object, passed on from the `renderListItem` function
104
+ * @param {ListItem} item the list item
105
+ * @returns {HTMLElement} the icon element
106
+ */
107
+ this.renderIcon = (config, item) => {
108
+ const style = {};
109
+ if (item.iconColor) {
110
+ if (config.badgeIcons) {
111
+ style['--icon-background-color'] = item.iconColor;
112
+ }
113
+ else {
114
+ style.color = item.iconColor;
115
+ }
116
+ }
117
+ return (h("limel-icon", { badge: config.badgeIcons, class: "mdc-deprecated-list-item__graphic", name: item.icon, style: style, size: config.iconSize }));
118
+ };
119
+ this.renderDivider = () => {
120
+ const classes = {
121
+ 'mdc-deprecated-list-divider': true,
122
+ 'mdc-deprecated-list-divider--inset': true,
123
+ };
124
+ if (this.config.iconSize) {
125
+ classes[this.config.iconSize] = true;
126
+ }
127
+ return h("hr", { class: classes });
128
+ };
129
+ this.renderActionMenu = (actions) => {
130
+ if (!actions || actions.length === 0) {
131
+ return;
132
+ }
133
+ return (h("limel-menu", { class: "mdc-deprecated-list-item__meta", items: actions, openDirection: "left" },
134
+ h("limel-icon", { slot: "trigger", name: "menu_2", size: "small" })));
135
+ };
136
+ this.renderVariantListItem = (config, item, index) => {
137
+ let itemTemplate;
138
+ if (config.type === 'radio') {
139
+ itemTemplate = (h(RadioButtonTemplate, { id: `c_${index}`, checked: item.selected, disabled: item.disabled }));
140
+ }
141
+ else if (config.type === 'checkbox') {
142
+ itemTemplate = (h(CheckboxTemplate, { id: `c_${index}`, checked: item.selected, disabled: item.disabled }));
143
+ }
144
+ const classNames = {
145
+ 'mdc-deprecated-list-item': true,
146
+ 'mdc-deprecated-list-item--disabled': item.disabled,
147
+ 'mdc-deprecated-list-item__text': !item.secondaryText,
148
+ };
149
+ const attributes = {};
150
+ if (index === this.applyTabIndexToItemAtIndex) {
151
+ attributes.tabindex = '0';
152
+ }
153
+ return (h("li", Object.assign({ class: classNames, role: config.type, "aria-checked": item.selected ? 'true' : 'false', "aria-disabled": item.disabled ? 'true' : 'false', "data-index": index }, attributes), this.renderVariantListItemContent(config, item, itemTemplate)));
154
+ };
155
+ this.renderVariantListItemContent = (config, item, itemTemplate) => {
156
+ if (this.hasIcons) {
157
+ return [
158
+ item.icon ? this.renderIcon(config, item) : null,
159
+ this.renderText(item),
160
+ h("div", { class: "mdc-deprecated-list-item__meta" }, itemTemplate),
161
+ ];
162
+ }
163
+ return [
164
+ h("div", { class: "mdc-deprecated-list-item__graphic" }, itemTemplate),
165
+ this.renderText(item),
166
+ ];
167
+ };
12
168
  }
13
169
  render(items, config = {}) {
14
170
  items = items || [];
@@ -48,162 +204,4 @@ export class ListRenderer {
48
204
  };
49
205
  return (h("ul", { class: classNames, "aria-hidden": (this.config.type === 'menu').toString(), role: role, "aria-orientation": "vertical" }, items.map(this.renderListItem)));
50
206
  }
51
- /**
52
- * Determine which ListItem should have the `tab-index` attribute set,
53
- * and return the index at which that ListItem is located in `items`.
54
- * Returns `undefined` if no item should have the attribute set.
55
- * See https://github.com/material-components/material-components-web/tree/e66a43a75fef4f9179e24856649518e15e279a04/packages/mdc-list#accessibility
56
- *
57
- * @param {Array<ListItem | ListSeparator | MenuItems>} items the items of the list, including any `ListSeparator`:s
58
- * @returns {number} the index as per the description
59
- */
60
- getIndexForWhichToApplyTabIndex(items) {
61
- let result;
62
- for (let i = 0, max = items.length; i < max; i += 1) {
63
- if ('separator' in items[i]) {
64
- // Ignore ListSeparator
65
- }
66
- else {
67
- const item = items[i];
68
- if (item.selected) {
69
- result = i;
70
- break;
71
- }
72
- if (result === undefined && !item.disabled) {
73
- result = i;
74
- // Do NOT break, as any later item with
75
- // `selected=true` should get the tab-index instead!
76
- }
77
- }
78
- }
79
- return result;
80
- }
81
- /**
82
- * Render a single list item
83
- *
84
- * @param {ListItem | ListSeparator | MenuItems} item the item to render
85
- * @param {number} index the index the item had in the `items` array
86
- * @returns {HTMLElement} the list item
87
- */
88
- renderListItem(item, index) {
89
- if ('separator' in item) {
90
- return h("li", { class: "mdc-deprecated-list-divider", role: "separator" });
91
- }
92
- if (['radio', 'checkbox'].includes(this.config.type)) {
93
- return this.renderVariantListItem(this.config, item, index);
94
- }
95
- const classNames = {
96
- 'mdc-deprecated-list-item': true,
97
- 'mdc-deprecated-list-item--disabled': item.disabled,
98
- 'mdc-deprecated-list-item--selected': item.selected,
99
- };
100
- const attributes = {};
101
- if (index === this.applyTabIndexToItemAtIndex) {
102
- attributes.tabindex = '0';
103
- }
104
- return (h("li", Object.assign({ class: classNames, role: this.config.type === 'menu' ? 'menuitem' : '', "aria-disabled": item.disabled ? 'true' : 'false', "aria-selected": item.selected ? 'true' : 'false', "data-index": index }, attributes),
105
- item.icon ? this.renderIcon(this.config, item) : null,
106
- this.renderText(item),
107
- this.twoLines && this.avatarList ? this.renderDivider() : null,
108
- this.renderActionMenu(item.actions)));
109
- }
110
- /**
111
- * Render the text of the list item
112
- *
113
- * @param {ListItem | MenuItem} item the list item
114
- * @returns {HTMLElement | string} the text for the list item
115
- */
116
- renderText(item) {
117
- if (this.isSimpleItem(item)) {
118
- return (h("span", { class: "mdc-deprecated-list-item__text" }, item.text));
119
- }
120
- return (h("div", { class: "mdc-deprecated-list-item__text" },
121
- h("div", { class: "mdc-deprecated-list-item__primary-command-text" },
122
- h("div", { class: "mdc-deprecated-list-item__primary-text" }, item.text),
123
- this.renderCommandText(item)),
124
- h("div", { class: "mdc-deprecated-list-item__secondary-text" }, item.secondaryText)));
125
- }
126
- renderCommandText(item) {
127
- if (!('commandText' in item)) {
128
- return;
129
- }
130
- return (h("div", { class: "mdc-deprecated-list-item__command-text" }, item.commandText));
131
- }
132
- isSimpleItem(item) {
133
- if ('commandText' in item) {
134
- return false;
135
- }
136
- if ('secondaryText' in item) {
137
- return false;
138
- }
139
- return true;
140
- }
141
- /**
142
- * Render an icon for a list item
143
- *
144
- * @param {ListRendererConfig} config the config object, passed on from the `renderListItem` function
145
- * @param {ListItem} item the list item
146
- * @returns {HTMLElement} the icon element
147
- */
148
- renderIcon(config, item) {
149
- const style = {};
150
- if (item.iconColor) {
151
- if (config.badgeIcons) {
152
- style['--icon-background-color'] = item.iconColor;
153
- }
154
- else {
155
- style.color = item.iconColor;
156
- }
157
- }
158
- return (h("limel-icon", { badge: config.badgeIcons, class: "mdc-deprecated-list-item__graphic", name: item.icon, style: style, size: config.iconSize }));
159
- }
160
- renderDivider() {
161
- const classes = {
162
- 'mdc-deprecated-list-divider': true,
163
- 'mdc-deprecated-list-divider--inset': true,
164
- };
165
- if (this.config.iconSize) {
166
- classes[this.config.iconSize] = true;
167
- }
168
- return h("hr", { class: classes });
169
- }
170
- renderActionMenu(actions) {
171
- if (!actions || actions.length === 0) {
172
- return;
173
- }
174
- return (h("limel-menu", { class: "mdc-deprecated-list-item__meta", items: actions, openDirection: "left" },
175
- h("limel-icon", { slot: "trigger", name: "menu_2", size: "small" })));
176
- }
177
- renderVariantListItem(config, item, index) {
178
- let itemTemplate;
179
- if (config.type === 'radio') {
180
- itemTemplate = (h(RadioButtonTemplate, { id: `c_${index}`, checked: item.selected, disabled: item.disabled }));
181
- }
182
- else if (config.type === 'checkbox') {
183
- itemTemplate = (h(CheckboxTemplate, { id: `c_${index}`, checked: item.selected, disabled: item.disabled }));
184
- }
185
- const classNames = {
186
- 'mdc-deprecated-list-item': true,
187
- 'mdc-deprecated-list-item--disabled': item.disabled,
188
- 'mdc-deprecated-list-item__text': !item.secondaryText,
189
- };
190
- const attributes = {};
191
- if (index === this.applyTabIndexToItemAtIndex) {
192
- attributes.tabindex = '0';
193
- }
194
- return (h("li", Object.assign({ class: classNames, role: config.type, "aria-checked": item.selected ? 'true' : 'false', "aria-disabled": item.disabled ? 'true' : 'false', "data-index": index }, attributes), this.renderVariantListItemContent(config, item, itemTemplate)));
195
- }
196
- renderVariantListItemContent(config, item, itemTemplate) {
197
- if (this.hasIcons) {
198
- return [
199
- item.icon ? this.renderIcon(config, item) : null,
200
- this.renderText(item),
201
- h("div", { class: "mdc-deprecated-list-item__meta" }, itemTemplate),
202
- ];
203
- }
204
- return [
205
- h("div", { class: "mdc-deprecated-list-item__graphic" }, itemTemplate),
206
- this.renderText(item),
207
- ];
208
- }
209
207
  }
@@ -37,8 +37,121 @@ export class List {
37
37
  // eslint-disable-next-line no-magic-numbers
38
38
  this.maxLinesSecondaryText = 3;
39
39
  this.listRenderer = new ListRenderer();
40
- this.handleAction = this.handleAction.bind(this);
41
- this.handleMenuSelect = this.handleMenuSelect.bind(this);
40
+ this.setup = () => {
41
+ if (this.type === 'menu') {
42
+ this.setupMenu();
43
+ }
44
+ else {
45
+ this.setupList();
46
+ }
47
+ this.setupListeners();
48
+ };
49
+ this.setupList = () => {
50
+ const element = this.element.shadowRoot.querySelector('.mdc-deprecated-list');
51
+ if (!element) {
52
+ return;
53
+ }
54
+ this.mdcList = new MDCList(element);
55
+ this.mdcList.listElements.forEach((item) => new MDCRipple(item));
56
+ };
57
+ this.setupMenu = () => {
58
+ const element = this.element.shadowRoot.querySelector('.mdc-menu');
59
+ if (!element) {
60
+ return;
61
+ }
62
+ this.mdcMenu = new MDCMenu(element);
63
+ this.mdcMenu.hasTypeahead = true;
64
+ this.mdcMenu.wrapFocus = true;
65
+ this.mdcMenu.items.forEach((item) => new MDCRipple(item));
66
+ };
67
+ this.setupListeners = () => {
68
+ if (this.type === 'menu') {
69
+ this.setupMenuListeners();
70
+ }
71
+ else {
72
+ this.setupListListeners();
73
+ }
74
+ };
75
+ this.setupListListeners = () => {
76
+ if (!this.mdcList) {
77
+ return;
78
+ }
79
+ this.mdcList.unlisten(ACTION_EVENT, this.handleAction);
80
+ this.selectable = ['selectable', 'radio', 'checkbox', 'menu'].includes(this.type);
81
+ this.multiple = this.type === 'checkbox';
82
+ if (!this.selectable) {
83
+ return;
84
+ }
85
+ this.mdcList.listen(ACTION_EVENT, this.handleAction);
86
+ this.mdcList.singleSelection = !this.multiple;
87
+ };
88
+ this.setupMenuListeners = () => {
89
+ if (!this.mdcMenu) {
90
+ return;
91
+ }
92
+ this.mdcMenu.unlisten(SELECTED_EVENT, this.handleMenuSelect);
93
+ this.selectable = true;
94
+ this.mdcMenu.listen(SELECTED_EVENT, this.handleMenuSelect);
95
+ };
96
+ this.teardown = () => {
97
+ var _a, _b, _c, _d;
98
+ (_a = this.mdcList) === null || _a === void 0 ? void 0 : _a.unlisten(ACTION_EVENT, this.handleAction);
99
+ (_b = this.mdcList) === null || _b === void 0 ? void 0 : _b.destroy();
100
+ (_c = this.mdcMenu) === null || _c === void 0 ? void 0 : _c.unlisten(SELECTED_EVENT, this.handleMenuSelect);
101
+ (_d = this.mdcMenu) === null || _d === void 0 ? void 0 : _d.destroy();
102
+ };
103
+ this.handleAction = (event) => {
104
+ if (!this.multiple) {
105
+ this.handleSingleSelect(event.detail.index);
106
+ return;
107
+ }
108
+ this.handleMultiSelect(event.detail.index);
109
+ };
110
+ this.handleMenuSelect = (event) => {
111
+ this.handleSingleSelect(event.detail.index);
112
+ };
113
+ this.handleSingleSelect = (index) => {
114
+ const listItems = this.items.filter(this.isListItem);
115
+ if (listItems[index].disabled) {
116
+ return;
117
+ }
118
+ const selectedItem = listItems.find((item) => {
119
+ return !!item.selected;
120
+ });
121
+ if (selectedItem) {
122
+ this.change.emit(Object.assign(Object.assign({}, selectedItem), { selected: false }));
123
+ }
124
+ if (listItems[index] !== selectedItem) {
125
+ if (this.type === 'menu') {
126
+ this.change.emit(Object.assign(Object.assign({}, listItems[index]), { selected: false }));
127
+ return;
128
+ }
129
+ this.change.emit(Object.assign(Object.assign({}, listItems[index]), { selected: true }));
130
+ }
131
+ };
132
+ this.handleMultiSelect = (index) => {
133
+ const listItems = this.items.filter(this.isListItem);
134
+ if (listItems[index].disabled) {
135
+ return;
136
+ }
137
+ const selectedItems = listItems
138
+ .filter((item, listIndex) => {
139
+ if (listIndex === index) {
140
+ // This is the item that was selected or deselected,
141
+ // so we negate its previous selection status.
142
+ return !item.selected;
143
+ }
144
+ // This is an item that didn't change, so we keep its selection status.
145
+ return item.selected;
146
+ })
147
+ .map((item) => {
148
+ return Object.assign(Object.assign({}, item), { selected: true });
149
+ });
150
+ this.change.emit(selectedItems);
151
+ };
152
+ this.isListItem = (item) => {
153
+ return !('separator' in item);
154
+ };
42
155
  }
43
156
  connectedCallback() {
44
157
  this.setup();
@@ -84,121 +197,6 @@ export class List {
84
197
  .filter((item) => item.selected)
85
198
  .map((item) => listItems.indexOf(item));
86
199
  }
87
- setup() {
88
- if (this.type === 'menu') {
89
- this.setupMenu();
90
- }
91
- else {
92
- this.setupList();
93
- }
94
- this.setupListeners();
95
- }
96
- setupList() {
97
- const element = this.element.shadowRoot.querySelector('.mdc-deprecated-list');
98
- if (!element) {
99
- return;
100
- }
101
- this.mdcList = new MDCList(element);
102
- this.mdcList.listElements.forEach((item) => new MDCRipple(item));
103
- }
104
- setupMenu() {
105
- const element = this.element.shadowRoot.querySelector('.mdc-menu');
106
- if (!element) {
107
- return;
108
- }
109
- this.mdcMenu = new MDCMenu(element);
110
- this.mdcMenu.hasTypeahead = true;
111
- this.mdcMenu.wrapFocus = true;
112
- this.mdcMenu.items.forEach((item) => new MDCRipple(item));
113
- }
114
- setupListeners() {
115
- if (this.type === 'menu') {
116
- this.setupMenuListeners();
117
- }
118
- else {
119
- this.setupListListeners();
120
- }
121
- }
122
- setupListListeners() {
123
- if (!this.mdcList) {
124
- return;
125
- }
126
- this.mdcList.unlisten(ACTION_EVENT, this.handleAction);
127
- this.selectable = ['selectable', 'radio', 'checkbox', 'menu'].includes(this.type);
128
- this.multiple = this.type === 'checkbox';
129
- if (!this.selectable) {
130
- return;
131
- }
132
- this.mdcList.listen(ACTION_EVENT, this.handleAction);
133
- this.mdcList.singleSelection = !this.multiple;
134
- }
135
- setupMenuListeners() {
136
- if (!this.mdcMenu) {
137
- return;
138
- }
139
- this.mdcMenu.unlisten(SELECTED_EVENT, this.handleMenuSelect);
140
- this.selectable = true;
141
- this.mdcMenu.listen(SELECTED_EVENT, this.handleMenuSelect);
142
- }
143
- teardown() {
144
- var _a, _b, _c, _d;
145
- (_a = this.mdcList) === null || _a === void 0 ? void 0 : _a.unlisten(ACTION_EVENT, this.handleAction);
146
- (_b = this.mdcList) === null || _b === void 0 ? void 0 : _b.destroy();
147
- (_c = this.mdcMenu) === null || _c === void 0 ? void 0 : _c.unlisten(SELECTED_EVENT, this.handleMenuSelect);
148
- (_d = this.mdcMenu) === null || _d === void 0 ? void 0 : _d.destroy();
149
- }
150
- handleAction(event) {
151
- if (!this.multiple) {
152
- this.handleSingleSelect(event.detail.index);
153
- return;
154
- }
155
- this.handleMultiSelect(event.detail.index);
156
- }
157
- handleMenuSelect(event) {
158
- this.handleSingleSelect(event.detail.index);
159
- }
160
- handleSingleSelect(index) {
161
- const listItems = this.items.filter(this.isListItem);
162
- if (listItems[index].disabled) {
163
- return;
164
- }
165
- const selectedItem = listItems.find((item) => {
166
- return !!item.selected;
167
- });
168
- if (selectedItem) {
169
- this.change.emit(Object.assign(Object.assign({}, selectedItem), { selected: false }));
170
- }
171
- if (listItems[index] !== selectedItem) {
172
- if (this.type === 'menu') {
173
- this.change.emit(Object.assign(Object.assign({}, listItems[index]), { selected: false }));
174
- return;
175
- }
176
- this.change.emit(Object.assign(Object.assign({}, listItems[index]), { selected: true }));
177
- }
178
- }
179
- handleMultiSelect(index) {
180
- const listItems = this.items.filter(this.isListItem);
181
- if (listItems[index].disabled) {
182
- return;
183
- }
184
- const selectedItems = listItems
185
- .filter((item, listIndex) => {
186
- if (listIndex === index) {
187
- // This is the item that was selected or deselected,
188
- // so we negate its previous selection status.
189
- return !item.selected;
190
- }
191
- // This is an item that didn't change, so we keep its selection status.
192
- return item.selected;
193
- })
194
- .map((item) => {
195
- return Object.assign(Object.assign({}, item), { selected: true });
196
- });
197
- this.change.emit(selectedItems);
198
- }
199
- isListItem(item) {
200
- return !('separator' in item);
201
- }
202
200
  static get is() { return "limel-list"; }
203
201
  static get encapsulation() { return "shadow"; }
204
202
  static get originalStyleUrls() { return {
@@ -211,7 +211,7 @@ export class Menu {
211
211
  "mutable": false,
212
212
  "complexType": {
213
213
  "original": "Array<MenuItem | ListSeparator>",
214
- "resolved": "(ListSeparator | MenuItem)[]",
214
+ "resolved": "(ListSeparator | MenuItem<any>)[]",
215
215
  "references": {
216
216
  "Array": {
217
217
  "location": "global"