@mapsindoors/map-template 1.95.1 → 1.95.2

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 (66) hide show
  1. package/dist/{GoogleMapsMap-C5n6Bgtp.mjs → GoogleMapsMap-Dkn60-_e.mjs} +2 -2
  2. package/dist/{MapboxMap-UCqzt1AC.mjs → MapboxMap-B1oo7IUm.mjs} +2 -2
  3. package/dist/_commonjsHelpers-B85MJLTf.js +5 -0
  4. package/dist/app-globals-DQuL1Twl.js +3 -0
  5. package/dist/combo-box-item.entry.js +8 -10
  6. package/dist/icon-DT_sDkmK.js +11 -0
  7. package/dist/index-BZQHyS7V.js +1701 -0
  8. package/dist/loader.js +7 -14
  9. package/dist/mapsindoors-react.es.js +1 -1
  10. package/dist/mapsindoors-react.umd.js +175 -175
  11. package/dist/mapsindoors-webcomponent.es.js +2916 -2904
  12. package/dist/mi-card_2.entry.js +23 -18
  13. package/dist/mi-chip.entry.js +25 -16
  14. package/dist/mi-column.entry.js +47 -23
  15. package/dist/mi-combo-box.entry.js +412 -379
  16. package/dist/mi-components.js +15 -12
  17. package/dist/mi-data-table.entry.js +298 -278
  18. package/dist/mi-distance_2.entry.js +58 -56
  19. package/dist/mi-dropdown-item.entry.js +8 -10
  20. package/dist/mi-dropdown.entry.js +525 -481
  21. package/dist/mi-floor-selector.entry.js +183 -180
  22. package/dist/mi-keyboard.entry.js +207 -186
  23. package/dist/mi-list-item-category.entry.js +44 -41
  24. package/dist/mi-list-item-location.entry.js +168 -162
  25. package/dist/mi-list.entry.js +56 -48
  26. package/dist/mi-location-booking.entry.js +320 -295
  27. package/dist/mi-location-info.entry.js +61 -53
  28. package/dist/mi-map-googlemaps.entry.js +369 -324
  29. package/dist/mi-map-mapbox.entry.js +502 -439
  30. package/dist/mi-metric-card.entry.js +50 -37
  31. package/dist/mi-my-position.entry.js +2341 -874
  32. package/dist/mi-notification.entry.js +112 -102
  33. package/dist/mi-route-instructions-heading.entry.js +70 -65
  34. package/dist/mi-route-instructions-maneuver-legacy.entry.js +80 -76
  35. package/dist/mi-route-instructions-maneuver.entry.js +80 -76
  36. package/dist/mi-route-instructions-step-legacy.entry.js +296 -282
  37. package/dist/mi-route-instructions-step.entry.js +313 -292
  38. package/dist/mi-route-instructions.entry.js +167 -150
  39. package/dist/mi-scroll-buttons.entry.js +104 -98
  40. package/dist/mi-search.entry.js +366 -325
  41. package/dist/mi-share-sms.entry.js +82 -70
  42. package/dist/mi-step-switcher.entry.js +34 -25
  43. package/dist/mi-tab-panel.entry.js +18 -18
  44. package/dist/mi-tab.entry.js +5 -7
  45. package/dist/mi-tabs.entry.js +42 -40
  46. package/dist/mi-time.entry.js +49 -49
  47. package/dist/mi-variables-CDNvnTkH.js +5 -0
  48. package/dist/{reactcomponent-DQsjxRIN.mjs → reactcomponent-2Oa1vSiK.mjs} +8996 -8660
  49. package/dist/route-travel-mode.enum-BvqP1fpw.js +9 -0
  50. package/dist/sort-order.enum-jsLAbYWg.js +566 -0
  51. package/dist/{unit-system.enum-eaefb53e.js → unit-system.enum-BwPgAWqL.js} +2 -2
  52. package/dist/utils-DNHzysQ6.js +61 -0
  53. package/package.json +1 -1
  54. package/dist/_commonjsHelpers-ba3f0406.js +0 -21
  55. package/dist/icon-b8d01d6f.js +0 -24
  56. package/dist/index-7e9696f3.js +0 -1678
  57. package/dist/mi-variables-9a6c8d4d.js +0 -6
  58. package/dist/polyfills/core-js.js +0 -11
  59. package/dist/polyfills/css-shim.js +0 -1
  60. package/dist/polyfills/dom.js +0 -79
  61. package/dist/polyfills/es5-html-element.js +0 -1
  62. package/dist/polyfills/index.js +0 -34
  63. package/dist/polyfills/system.js +0 -6
  64. package/dist/route-travel-mode.enum-7f4ce9c7.js +0 -9
  65. package/dist/sort-order.enum-64ce8998.js +0 -552
  66. package/dist/utils-ae714467.js +0 -61
@@ -1,6 +1,6 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-7e9696f3.js';
2
- import { S as SortOrder, f as fuzzysort } from './sort-order.enum-64ce8998.js';
3
- import './_commonjsHelpers-ba3f0406.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-BZQHyS7V.js';
2
+ import { S as SortOrder, f as fuzzysort } from './sort-order.enum-jsLAbYWg.js';
3
+ import './_commonjsHelpers-B85MJLTf.js';
4
4
 
5
5
  /**
6
6
  * Performs function composition in LTR (Left To Right) direction.
@@ -107,504 +107,548 @@ var transformToLowerCase = function (text) { return text.toLocaleLowerCase(); };
107
107
  */
108
108
  var normalizeText = /*#__PURE__*/ pipe(resolveToText, normalizeDiacritics, normalizeWhiteSpaces, transformToLowerCase);
109
109
 
110
- const dropdownCss = ".mi-input[type=text],.mi-input[type=search],.mi-input[type=number],.mi-input[type=password],.mi-input[type=tel]{font-size:1rem;padding:8px;border-style:solid;border-width:1px;border-color:#8d98aa;border-radius:4px}.mi-input[type=text],.mi-input[type=search],.mi-input[type=number],.mi-input[type=password],.mi-input[type=range],.mi-input[type=tel]{display:block}.mi-input[type=radio],.mi-input[type=checkbox]{margin:0px;transform:scale(1.2, 1.2)}.mi-input[type=search]{padding-left:32px;background:url(\"data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.6267 8.43836C14.6267 11.8561 11.8561 14.6267 8.43836 14.6267C5.02062 14.6267 2.25 11.8561 2.25 8.43836C2.25 5.02062 5.02062 2.25 8.43836 2.25C11.8561 2.25 14.6267 5.02062 14.6267 8.43836Z' stroke='%23aeb9cb' stroke-width='2.5'/%3E%3Crect x='15.0979' y='14.1614' width='7.34678' height='1.32449' rx='0.662244' transform='rotate(45 15.0979 14.1614)' fill='%23aeb9cb' stroke='%23aeb9cb'/%3E%3Crect x='13.7847' y='13.2916' width='1.05276' height='0.697347' transform='rotate(45 13.7847 13.2916)' stroke='%23aeb9cb' stroke-width='0.697346'/%3E%3C/svg%3E%0A\") no-repeat scroll 8px center, white}.mi-input:disabled{opacity:0.48;cursor:not-allowed}.mi-label{font-style:normal;display:block;font-size:1rem;font-weight:500;color:#1e2025}.mi-label>*{margin-top:4px}.mi-label>input[type=radio],.mi-label>input[type=checkbox],.mi-label>label.mi-toggle-btn{margin-right:8px}mi-dropdown-item{display:none}:host{display:inline-block;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;font-family:Figtree, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}:host(.open) .button::after{border-top-color:transparent;border-bottom-color:#1f2937;margin-top:-8px}:host(.open) section{display:flex}:host(.open) svg.arrow{transform:rotate(180deg)}.button{display:flex;justify-content:flex-start;align-items:center;height:100%;width:100%;font-family:inherit;background:linear-gradient(#f9fafb, #f3f4f6);padding:0;padding-left:16px;padding-right:16px;border-radius:4px;border-width:1px;border-style:solid;border-color:#d1d5db;color:#1c1917;font-size:1rem;font-weight:500;line-height:1rem;gap:8px}.button__left-icon{height:20px;width:20px}.button svg{margin-left:auto}.button__label{padding-top:12px;padding-bottom:12px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.button__label--from-inner-html{display:grid;grid-auto-flow:column;grid-template-columns:24px 1fr;gap:8px;place-items:center}.button:disabled{opacity:0.72;cursor:not-allowed}.content{padding-top:12px;padding-bottom:12px;margin-top:12px;margin-bottom:12px;border-radius:8px;color:#1c1917;font-size:1rem;font-weight:500;background-color:#fcfcfc;box-shadow:0px 2px 2px rgba(0, 0, 0, 0.2), 0px 4px 4px rgba(0, 0, 0, 0.18), 0px 8px 8px rgba(0, 0, 0, 0.16);min-width:320px;max-width:480px;max-height:580px;display:none;flex-direction:column;position:fixed;z-index:10000}.content .filter{margin-bottom:16px;padding-left:8px;padding-right:8px;display:flex;position:relative}.content .filter__input{width:100%}.content .filter__clear{width:20px;height:20px;padding:0;border-width:0;display:flex;align-items:center;justify-content:center;position:absolute;right:14px;top:50%;transform:translateY(-50%);background-color:#1f2937;border-radius:50%}.content .filter__clear:focus{outline:0}.content .filter__clear--hidden{opacity:0;pointer-events:none}.content .filter__clear svg{fill:#fcfcfc;width:10px;height:10px}.content .options{margin-bottom:16px;padding-left:16px;padding-right:16px}.content .options__item{padding:0;color:#3b82f6;font-size:0.75rem;font-weight:500;font-family:inherit;background-color:transparent;border:transparent}.content .options__item:hover{text-decoration:underline}.content .options__item:first-child{margin-right:16px}.content .options__item:disabled{color:rgba(48, 113, 217, 0.72);cursor:not-allowed;text-decoration:none}.content .list{padding:0;margin:0;list-style:none;overflow-y:auto}.content .list__item{cursor:pointer}.content .list__item--disabled{opacity:0.72}.content .list__item--highlighted{background-color:#f3f4f6}.empty-page{display:flex;align-items:left;flex-direction:column;margin-left:16px;margin-bottom:12px}.empty-page>*{margin:0}.empty-page__header{font-size:1rem;font-weight:400;color:#374151}.label{display:flex;flex-direction:row;align-items:center;padding-left:16px;padding-right:16px;padding-top:8px;padding-bottom:8px}.label__item{display:inline-block;margin-top:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.label__item--from-inner-html{display:grid;grid-auto-flow:column;grid-template-columns:24px 1fr;gap:8px;place-items:center}.label__checkbox{margin-right:12px}.label__checkbox--hidden{display:none}";
110
+ const dropdownCss = () => `.mi-input[type=text],.mi-input[type=search],.mi-input[type=number],.mi-input[type=password],.mi-input[type=tel]{font-size:1rem;padding:8px;border-style:solid;border-width:1px;border-color:#8d98aa;border-radius:4px}.mi-input[type=text],.mi-input[type=search],.mi-input[type=number],.mi-input[type=password],.mi-input[type=range],.mi-input[type=tel]{display:block}.mi-input[type=radio],.mi-input[type=checkbox]{margin:0px;transform:scale(1.2, 1.2)}.mi-input[type=search]{padding-left:32px;background:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.6267 8.43836C14.6267 11.8561 11.8561 14.6267 8.43836 14.6267C5.02062 14.6267 2.25 11.8561 2.25 8.43836C2.25 5.02062 5.02062 2.25 8.43836 2.25C11.8561 2.25 14.6267 5.02062 14.6267 8.43836Z' stroke='%23aeb9cb' stroke-width='2.5'/%3E%3Crect x='15.0979' y='14.1614' width='7.34678' height='1.32449' rx='0.662244' transform='rotate(45 15.0979 14.1614)' fill='%23aeb9cb' stroke='%23aeb9cb'/%3E%3Crect x='13.7847' y='13.2916' width='1.05276' height='0.697347' transform='rotate(45 13.7847 13.2916)' stroke='%23aeb9cb' stroke-width='0.697346'/%3E%3C/svg%3E%0A") no-repeat scroll 8px center, white}.mi-input:disabled{opacity:0.48;cursor:not-allowed}.mi-label{font-style:normal;display:block;font-size:1rem;font-weight:500;color:#1e2025}.mi-label>*{margin-top:4px}.mi-label>input[type=radio],.mi-label>input[type=checkbox],.mi-label>label.mi-toggle-btn{margin-right:8px}mi-dropdown-item{display:none}:host{display:inline-block;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;font-family:Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"}:host(.open) .button::after{border-top-color:transparent;border-bottom-color:#1f2937;margin-top:-8px}:host(.open) section{display:flex}:host(.open) svg.arrow{transform:rotate(180deg)}.button{display:flex;justify-content:flex-start;align-items:center;height:100%;width:100%;font-family:inherit;background:linear-gradient(#f9fafb, #f3f4f6);padding:0;padding-left:16px;padding-right:16px;border-radius:4px;border-width:1px;border-style:solid;border-color:#d1d5db;color:#1c1917;font-size:1rem;font-weight:500;line-height:1rem;gap:8px}.button__left-icon{height:20px;width:20px}.button svg{margin-left:auto}.button__label{padding-top:12px;padding-bottom:12px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.button__label--from-inner-html{display:grid;grid-auto-flow:column;grid-template-columns:24px 1fr;gap:8px;place-items:center}.button:disabled{opacity:0.72;cursor:not-allowed}.content{padding-top:12px;padding-bottom:12px;margin-top:12px;margin-bottom:12px;border-radius:8px;color:#1c1917;font-size:1rem;font-weight:500;background-color:#fcfcfc;box-shadow:0px 2px 2px rgba(0, 0, 0, 0.2), 0px 4px 4px rgba(0, 0, 0, 0.18), 0px 8px 8px rgba(0, 0, 0, 0.16);min-width:320px;max-width:480px;max-height:580px;display:none;flex-direction:column;position:fixed;z-index:10000}.content .filter{margin-bottom:16px;padding-left:8px;padding-right:8px;display:flex;position:relative}.content .filter__input{width:100%}.content .filter__clear{width:20px;height:20px;padding:0;border-width:0;display:flex;align-items:center;justify-content:center;position:absolute;right:14px;top:50%;transform:translateY(-50%);background-color:#1f2937;border-radius:50%}.content .filter__clear:focus{outline:0}.content .filter__clear--hidden{opacity:0;pointer-events:none}.content .filter__clear svg{fill:#fcfcfc;width:10px;height:10px}.content .options{margin-bottom:16px;padding-left:16px;padding-right:16px}.content .options__item{padding:0;color:#3b82f6;font-size:0.75rem;font-weight:500;font-family:inherit;background-color:transparent;border:transparent}.content .options__item:hover{text-decoration:underline}.content .options__item:first-child{margin-right:16px}.content .options__item:disabled{color:rgba(48, 113, 217, 0.72);cursor:not-allowed;text-decoration:none}.content .list{padding:0;margin:0;list-style:none;overflow-y:auto}.content .list__item{cursor:pointer}.content .list__item--disabled{opacity:0.72}.content .list__item--highlighted{background-color:#f3f4f6}.empty-page{display:flex;align-items:left;flex-direction:column;margin-left:16px;margin-bottom:12px}.empty-page>*{margin:0}.empty-page__header{font-size:1rem;font-weight:400;color:#374151}.label{display:flex;flex-direction:row;align-items:center;padding-left:16px;padding-right:16px;padding-top:8px;padding-bottom:8px}.label__item{display:inline-block;margin-top:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.label__item--from-inner-html{display:grid;grid-auto-flow:column;grid-template-columns:24px 1fr;gap:8px;place-items:center}.label__checkbox{margin-right:12px}.label__checkbox--hidden{display:none}`;
111
111
 
112
112
  var KeyCode;
113
113
  (function (KeyCode) {
114
- KeyCode["ArrowDown"] = "ArrowDown";
115
- KeyCode["ArrowUp"] = "ArrowUp";
116
- KeyCode["Enter"] = "Enter";
117
- KeyCode["Esc"] = "Escape";
114
+ KeyCode["ArrowDown"] = "ArrowDown";
115
+ KeyCode["ArrowUp"] = "ArrowUp";
116
+ KeyCode["Enter"] = "Enter";
117
+ KeyCode["Esc"] = "Escape";
118
118
  })(KeyCode || (KeyCode = {}));
119
119
  const Dropdown = class {
120
- constructor(hostRef) {
121
- registerInstance(this, hostRef);
122
- this.change = createEvent(this, "change", 3);
123
- this.cleared = createEvent(this, "cleared", 7);
120
+ constructor(hostRef) {
121
+ registerInstance(this, hostRef);
122
+ this.change = createEvent(this, "change", 3);
123
+ this.cleared = createEvent(this, "cleared", 7);
124
+ /**
125
+ * Gets or sets the state of the dropdown.
126
+ * If the attribute is set to true then the dropdown will be expanded.
127
+ *
128
+ * @type {boolean}
129
+ */
130
+ this.open = false;
131
+ /**
132
+ * Gets or sets the list items.
133
+ *
134
+ * @type {Array<HTMLMiDropdownItemElement>}
135
+ */
136
+ this.items = [];
137
+ /**
138
+ * This attribute indicates that the items can be filtered using the input field present at the top.
139
+ * If it is not specified, the input field will not be visible, and filtering is not possible.
140
+ *
141
+ * @type {boolean}
142
+ */
143
+ this.filterable = false;
144
+ /**
145
+ * If present, it dictates placeholder for an filterable input field in the dropdown. Defaults to 'Type to filter...'.
146
+ *
147
+ * @type {string}
148
+ */
149
+ this.placeholder = 'Type to filter...';
150
+ /**
151
+ * This attribute indicates that multiple items can be selected in the list. If it is not specified, then only one item can be selected at a time.
152
+ *
153
+ * @type {boolean}
154
+ */
155
+ this.multiple = false;
156
+ /**
157
+ * Gets the selected items.
158
+ *
159
+ * @type {Array<HTMLMiDropdownItemElement>}
160
+ */
161
+ this.selected = [];
162
+ /**
163
+ * Guiding message when presented with a content window that has no rows.
164
+ * Default language is English.
165
+ */
166
+ this.noResultsMessage = 'No results found';
167
+ /**
168
+ * Sets the alignment of the dropdown. The default alignment is 'left'.
169
+ *
170
+ * @type {('right' | 'left')}
171
+ */
172
+ this.dropdownAlignment = 'left';
173
+ this.currentItems = [];
174
+ /**
175
+ * Sets the disabled state for the dropdown.
176
+ */
177
+ this.disabled = false;
178
+ /**
179
+ * Sets the disabled state of the select buttons in the filterable version of the component.
180
+ */
181
+ this.isFilterSelectionDisabled = false;
182
+ /**
183
+ * Flag to control the visibility of the clear button for filterable components.
184
+ */
185
+ this.isClearButtonVisible = false;
186
+ /**
187
+ * Flag to control the mouseover event on the items. The event is disabled when using the arrow keys to navigate the list.
188
+ */
189
+ this.isMouseOverEventDisabled = false;
190
+ this.currentItemIndex = 0;
191
+ this.selectedItemIndex = 0;
192
+ this.highlightedItemClassName = 'list__item--highlighted';
193
+ }
124
194
  /**
125
- * Sets the disabled state of the select buttons in the filterable version of the component.
195
+ * Watcher for items property.
126
196
  */
127
- this.isFilterSelectionDisabled = false;
197
+ onItemsChanged(items) {
198
+ if (items.some(item => item.tagName.toLowerCase() !== 'mi-dropdown-item')) {
199
+ throw new Error('Items contains unknown element(s).');
200
+ }
201
+ if (Object.values(SortOrder).includes(this.itemsOrder)) {
202
+ items = this.getSortedItems(items);
203
+ }
204
+ this.currentItems = [...items];
205
+ this.filter();
206
+ if (!this.multiple) {
207
+ const selectedItemIndex = this.currentItems.findIndex(item => item.selected);
208
+ this.currentItemIndex = selectedItemIndex > -1 ? selectedItemIndex : 0;
209
+ this.selectedItemIndex = this.currentItemIndex;
210
+ }
211
+ this.items.forEach((item, itemIndex) => {
212
+ item.dataset.index = itemIndex.toString();
213
+ item.dataset.excludefromall = `${item.excludefromall}`;
214
+ });
215
+ this.selectFirstMiDropdownItem();
216
+ }
128
217
  /**
129
- * Flag to control the visibility of the clear button for filterable components.
218
+ * Watcher for currentItems property.
130
219
  */
131
- this.isClearButtonVisible = false;
220
+ onCurrentItemsChange() {
221
+ this.isFilterSelectionDisabled = this.currentItems.length === 0;
222
+ }
132
223
  /**
133
- * Flag to control the mouseover event on the items. The event is disabled when using the arrow keys to navigate the list.
224
+ * Keyboard event listener.
225
+ * When the Tab key is pressed, the focus is set to the filter input field (If present).
226
+ *
227
+ * @param {KeyboardEvent} event
228
+ * @returns {void}
134
229
  */
135
- this.isMouseOverEventDisabled = false;
136
- this.currentItemIndex = 0;
137
- this.selectedItemIndex = 0;
138
- this.highlightedItemClassName = 'list__item--highlighted';
139
- this.open = false;
140
- this.items = [];
141
- this.itemsOrder = undefined;
142
- this.label = undefined;
143
- this.filterable = false;
144
- this.placeholder = 'Type to filter...';
145
- this.multiple = false;
146
- this.selected = [];
147
- this.noResultsMessage = 'No results found';
148
- this.iconSrc = undefined;
149
- this.iconAlt = undefined;
150
- this.dropdownAlignment = 'left';
151
- this.currentItems = [];
152
- this.disabled = false;
153
- }
154
- /**
155
- * Watcher for items property.
156
- */
157
- onItemsChanged(items) {
158
- if (items.some(item => item.tagName.toLowerCase() !== 'mi-dropdown-item')) {
159
- throw new Error('Items contains unknown element(s).');
160
- }
161
- if (Object.values(SortOrder).includes(this.itemsOrder)) {
162
- items = this.getSortedItems(items);
163
- }
164
- this.currentItems = [...items];
165
- this.filter();
166
- if (!this.multiple) {
167
- const selectedItemIndex = this.currentItems.findIndex(item => item.selected);
168
- this.currentItemIndex = selectedItemIndex > -1 ? selectedItemIndex : 0;
169
- this.selectedItemIndex = this.currentItemIndex;
170
- }
171
- this.items.forEach((item, itemIndex) => {
172
- item.dataset.index = itemIndex.toString();
173
- item.dataset.excludefromall = `${item.excludefromall}`;
174
- });
175
- this.selectFirstMiDropdownItem();
176
- }
177
- /**
178
- * Watcher for currentItems property.
179
- */
180
- onCurrentItemsChange() {
181
- this.isFilterSelectionDisabled = this.currentItems.length === 0;
182
- }
183
- /**
184
- * Keyboard event listener.
185
- * When the Tab key is pressed, the focus is set to the filter input field (If present).
186
- *
187
- * @param {KeyboardEvent} event
188
- * @returns {void}
189
- */
190
- handleKeyDown(event) {
191
- var _a;
192
- if (event.key === 'Tab' && this.open) {
193
- (_a = this.filterElement) === null || _a === void 0 ? void 0 : _a.focus();
194
- event.preventDefault();
195
- }
196
- }
197
- /**
198
- * Outside the dropdown listener. It will close the dropdown when a click is outside a dropdown and dropdown list.
199
- *
200
- * @param {Event} event
201
- */
202
- checkForClickOutside(event) {
203
- if (!this.hostElement.contains(event.target)) {
204
- this.open = false;
205
- }
206
- }
207
- /**
208
- * Mousemove event handler.
209
- * When the mouse is moved the mouseover event handler is enabled.
210
- */
211
- mouseMoveEventHandler() {
212
- this.isMouseOverEventDisabled = false;
213
- }
214
- /**
215
- * Scroll event handler.
216
- * The dropdown is closed when the scroll event is trigget outside the dropdown.
217
- */
218
- scrollEventHandler(event) {
219
- const target = event.target;
220
- if (!target || !this.hostElement.contains(target)) {
221
- this.open = false;
222
- }
223
- }
224
- /**
225
- * Resize event handler.
226
- * Recalculate the position of the dropdown when the window is resized.
227
- */
228
- resizeEventHandler() {
229
- this.calculateDropDownPosition();
230
- }
231
- /**
232
- * Lifecycle method called when the component is loaded in the DOM.
233
- */
234
- componentDidLoad() {
235
- this.createMiDropdownItemsFromDocument();
236
- this.selectFirstMiDropdownItem();
237
- this.enableKeyboardNavigationEvents();
238
- const filterElementObserver = new IntersectionObserver((entries) => {
239
- entries.forEach(entry => {
240
- if (entry.isIntersecting === true) {
241
- this.filterElement.focus();
230
+ handleKeyDown(event) {
231
+ var _a;
232
+ if (event.key === 'Tab' && this.open) {
233
+ (_a = this.filterElement) === null || _a === void 0 ? void 0 : _a.focus();
234
+ event.preventDefault();
242
235
  }
243
- });
244
- });
245
- if (this.filterElement !== undefined) {
246
- filterElementObserver.observe(this.filterElement);
247
- this.filterElement.addEventListener('keydown', (event) => {
248
- if (event.key === KeyCode.ArrowDown || event.key === KeyCode.ArrowUp) {
249
- event.preventDefault();
236
+ }
237
+ /**
238
+ * Outside the dropdown listener. It will close the dropdown when a click is outside a dropdown and dropdown list.
239
+ *
240
+ * @param {Event} event
241
+ */
242
+ checkForClickOutside(event) {
243
+ if (!this.hostElement.contains(event.target)) {
244
+ this.open = false;
250
245
  }
251
- });
252
- }
253
- }
254
- /**
255
- * Lifecycle method called when the component is updated.
256
- */
257
- componentDidRender() {
258
- this.calculateDropDownPosition();
259
- if (!this.multiple) {
260
- // Makes sure that an item is always highlighted when the content window is open.
261
- this.highlightItem(this.currentItemIndex, true);
262
- }
263
- }
264
- /**
265
- * Gets all mi-dropdown-item elements for the mi-dropdown items property.
266
- */
267
- createMiDropdownItemsFromDocument() {
268
- const items = this.items && this.items.length > 0 ? this.items : this.hostElement.querySelectorAll('mi-dropdown-item');
269
- if (items.length > 0) {
270
- this.items = Array.from(items);
271
- }
272
- }
273
- /**
274
- * Set the first mi-dropdown-item as the textual content of the button.
275
- */
276
- selectFirstMiDropdownItem() {
277
- var _a;
278
- if (!this.multiple) {
279
- const selectedIndex = (_a = this.items) === null || _a === void 0 ? void 0 : _a.findIndex((item) => { return item.selected; });
280
- this.selected = [this.items[selectedIndex > -1 ? selectedIndex : 0]];
281
- }
282
- }
283
- /**
284
- * Enables cycling through the items in the content window using arrow up/down keys.
285
- */
286
- enableKeyboardNavigationEvents() {
287
- this.hostElement.addEventListener('keydown', event => {
288
- if (this.open === false && event.key === KeyCode.ArrowDown) {
289
- this.isMouseOverEventDisabled = true;
290
- this.toggleContentWindow();
291
- event.preventDefault();
292
- return;
293
- }
294
- if (this.open === true && !this.multiple) {
295
- switch (event.key) {
296
- case KeyCode.ArrowDown:
297
- this.isMouseOverEventDisabled = true;
298
- this.currentItemIndex = (this.currentItemIndex + 1) % this.currentItems.length;
299
- this.highlightItem(this.currentItemIndex, true);
300
- event.preventDefault();
301
- break;
302
- case KeyCode.ArrowUp:
303
- this.isMouseOverEventDisabled = true;
304
- this.currentItemIndex = ((this.currentItemIndex + this.currentItems.length) - 1) % this.currentItems.length;
246
+ }
247
+ /**
248
+ * Mousemove event handler.
249
+ * When the mouse is moved the mouseover event handler is enabled.
250
+ */
251
+ mouseMoveEventHandler() {
252
+ this.isMouseOverEventDisabled = false;
253
+ }
254
+ /**
255
+ * Scroll event handler.
256
+ * The dropdown is closed when the scroll event is trigget outside the dropdown.
257
+ */
258
+ scrollEventHandler(event) {
259
+ const target = event.target;
260
+ if (!target || !this.hostElement.contains(target)) {
261
+ this.open = false;
262
+ }
263
+ }
264
+ /**
265
+ * Resize event handler.
266
+ * Recalculate the position of the dropdown when the window is resized.
267
+ */
268
+ resizeEventHandler() {
269
+ this.calculateDropDownPosition();
270
+ }
271
+ /**
272
+ * Lifecycle method called when the component is loaded in the DOM.
273
+ */
274
+ componentDidLoad() {
275
+ this.createMiDropdownItemsFromDocument();
276
+ this.selectFirstMiDropdownItem();
277
+ this.enableKeyboardNavigationEvents();
278
+ const filterElementObserver = new IntersectionObserver((entries) => {
279
+ entries.forEach(entry => {
280
+ if (entry.isIntersecting === true) {
281
+ this.filterElement.focus();
282
+ }
283
+ });
284
+ });
285
+ if (this.filterElement !== undefined) {
286
+ filterElementObserver.observe(this.filterElement);
287
+ this.filterElement.addEventListener('keydown', (event) => {
288
+ if (event.key === KeyCode.ArrowDown || event.key === KeyCode.ArrowUp) {
289
+ event.preventDefault();
290
+ }
291
+ });
292
+ }
293
+ }
294
+ /**
295
+ * Lifecycle method called when the component is updated.
296
+ */
297
+ componentDidRender() {
298
+ this.calculateDropDownPosition();
299
+ if (!this.multiple) {
300
+ // Makes sure that an item is always highlighted when the content window is open.
305
301
  this.highlightItem(this.currentItemIndex, true);
306
- event.preventDefault();
307
- break;
308
- case KeyCode.Enter:
309
- if (this.hostElement.shadowRoot.activeElement === this.clearButtonElement) {
310
- // When the clear button is focused and Enter is pressed, don't select the
311
- // currently highlighted item or close the content window.
312
- return;
302
+ }
303
+ }
304
+ /**
305
+ * Gets all mi-dropdown-item elements for the mi-dropdown items property.
306
+ */
307
+ createMiDropdownItemsFromDocument() {
308
+ const items = this.items && this.items.length > 0 ? this.items : this.hostElement.querySelectorAll('mi-dropdown-item');
309
+ if (items.length > 0) {
310
+ this.items = Array.from(items);
311
+ }
312
+ }
313
+ /**
314
+ * Set the first mi-dropdown-item as the textual content of the button.
315
+ */
316
+ selectFirstMiDropdownItem() {
317
+ var _a;
318
+ if (!this.multiple) {
319
+ const selectedIndex = (_a = this.items) === null || _a === void 0 ? void 0 : _a.findIndex((item) => { return item.selected; });
320
+ this.selected = [this.items[selectedIndex > -1 ? selectedIndex : 0]];
321
+ }
322
+ }
323
+ /**
324
+ * Enables cycling through the items in the content window using arrow up/down keys.
325
+ */
326
+ enableKeyboardNavigationEvents() {
327
+ this.hostElement.addEventListener('keydown', event => {
328
+ if (this.open === false && event.key === KeyCode.ArrowDown) {
329
+ this.isMouseOverEventDisabled = true;
330
+ this.toggleContentWindow();
331
+ event.preventDefault();
332
+ return;
313
333
  }
314
- if (this.currentItems[this.currentItemIndex] !== undefined) {
315
- this.onSelect(this.currentItems[this.currentItemIndex]);
334
+ if (this.open === true && !this.multiple) {
335
+ switch (event.key) {
336
+ case KeyCode.ArrowDown:
337
+ this.isMouseOverEventDisabled = true;
338
+ this.currentItemIndex = (this.currentItemIndex + 1) % this.currentItems.length;
339
+ this.highlightItem(this.currentItemIndex, true);
340
+ event.preventDefault();
341
+ break;
342
+ case KeyCode.ArrowUp:
343
+ this.isMouseOverEventDisabled = true;
344
+ this.currentItemIndex = ((this.currentItemIndex + this.currentItems.length) - 1) % this.currentItems.length;
345
+ this.highlightItem(this.currentItemIndex, true);
346
+ event.preventDefault();
347
+ break;
348
+ case KeyCode.Enter:
349
+ if (this.hostElement.shadowRoot.activeElement === this.clearButtonElement) {
350
+ // When the clear button is focused and Enter is pressed, don't select the
351
+ // currently highlighted item or close the content window.
352
+ return;
353
+ }
354
+ if (this.currentItems[this.currentItemIndex] !== undefined) {
355
+ this.onSelect(this.currentItems[this.currentItemIndex]);
356
+ }
357
+ event.preventDefault();
358
+ break;
359
+ }
316
360
  }
317
- event.preventDefault();
318
- break;
361
+ // This case must be applied to all types of the dropdown component.
362
+ if (event.key === KeyCode.Esc) {
363
+ if (!this.multiple) {
364
+ this.currentItemIndex = this.selectedItemIndex;
365
+ this.highlightItem(this.currentItemIndex);
366
+ }
367
+ this.toggleContentWindow();
368
+ this.clearFilter();
369
+ }
370
+ });
371
+ }
372
+ /**
373
+ * Updates the currently highlighted item in the markup.
374
+ *
375
+ * @param {number} itemIndex
376
+ */
377
+ highlightItem(itemIndex, scrollIntoView = false) {
378
+ var _a, _b;
379
+ const items = this.hostElement.shadowRoot.querySelectorAll('.list__item');
380
+ items.forEach(item => {
381
+ item.classList.remove(this.highlightedItemClassName);
382
+ });
383
+ (_a = items[itemIndex]) === null || _a === void 0 ? void 0 : _a.classList.add(this.highlightedItemClassName);
384
+ if (scrollIntoView) {
385
+ (_b = items[itemIndex]) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest', inline: 'nearest' });
386
+ }
387
+ }
388
+ /**
389
+ * Get sorted items.
390
+ * The sorting order is defined by the itemsOrder attribute.
391
+ *
392
+ * @param {HTMLMiDropdownItemElement[]} items
393
+ * @returns {HTMLMiDropdownItemElement[]}
394
+ */
395
+ getSortedItems(items) {
396
+ if (this.itemsOrder === SortOrder.Asc) {
397
+ // Ascending order
398
+ items.sort((a, b) => (a.text || a.innerText)
399
+ .trimStart()
400
+ .toLowerCase()
401
+ .localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
319
402
  }
320
- }
321
- // This case must be applied to all types of the dropdown component.
322
- if (event.key === KeyCode.Esc) {
403
+ else {
404
+ // Descending order
405
+ items.sort((b, a) => (a.text || a.innerText)
406
+ .trimStart()
407
+ .toLowerCase()
408
+ .localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
409
+ }
410
+ return items;
411
+ }
412
+ /**
413
+ * Update and emit list of selected items.
414
+ */
415
+ onChangedHandler() {
416
+ this.selected = [...this.items.filter(item => item.selected)];
417
+ this.change.emit(this.selected);
418
+ }
419
+ /**
420
+ * Toggle visibility of content window.
421
+ */
422
+ toggleContentWindow() {
423
+ this.open = !this.open;
424
+ }
425
+ /**
426
+ * Check all checkboxes.
427
+ */
428
+ selectAll() {
429
+ const items = Array.from(this.currentItems);
430
+ for (const item of items) {
431
+ item.selected = (`${item.dataset.excludefromall}` === 'true' || item.disabled) ? false : true;
432
+ }
433
+ this.onChangedHandler();
434
+ }
435
+ /**
436
+ * Uncheck all checkboxes.
437
+ */
438
+ selectNone() {
439
+ const items = Array.from(this.currentItems);
440
+ for (const item of items) {
441
+ item.selected = false;
442
+ }
443
+ this.onChangedHandler();
444
+ }
445
+ /**
446
+ * Select or toggle selection of item.
447
+ *
448
+ * @param {HTMLMiDropdownItemElement} item
449
+ */
450
+ onSelect(item) {
323
451
  if (!this.multiple) {
324
- this.currentItemIndex = this.selectedItemIndex;
325
- this.highlightItem(this.currentItemIndex);
452
+ this.open = false;
453
+ const items = Array.from(this.items);
454
+ items.forEach((item) => { item.selected = false; });
455
+ this.clearFilter();
456
+ }
457
+ item.selected = !item.selected;
458
+ this.currentItemIndex = Number(item.dataset.index);
459
+ this.selectedItemIndex = this.currentItemIndex;
460
+ this.onChangedHandler();
461
+ }
462
+ /**
463
+ * Highlights the item that the cursor is hovering in the content window.
464
+ *
465
+ * @param {number} filteredItemsIndex
466
+ */
467
+ onMouseOver(filteredItemsIndex) {
468
+ if (!this.isMouseOverEventDisabled && !this.multiple) {
469
+ this.highlightItem(filteredItemsIndex);
470
+ this.currentItemIndex = filteredItemsIndex;
471
+ }
472
+ }
473
+ /**
474
+ * Filter items based on the input query.
475
+ */
476
+ filter() {
477
+ if (this.filterElement) {
478
+ const inputQuery = this.filterElement.value;
479
+ // Normalize text by trimming whitespace, converting to lowercase, and removing diacritics.
480
+ // This ensures consistent matching/comparison of dropdown items.
481
+ const miDropdownItemTexts = this.items.map(item => (normalizeText(item.text) || normalizeText(item.innerText)));
482
+ const numberOfItemsDisplayed = this.currentItems.length;
483
+ if (inputQuery === '') {
484
+ this.currentItemIndex = this.selectedItemIndex;
485
+ this.isClearButtonVisible = false;
486
+ this.currentItems = [...this.items];
487
+ return;
488
+ }
489
+ else {
490
+ this.isClearButtonVisible = true;
491
+ }
492
+ const searchResultsOptions = {
493
+ limit: 50,
494
+ allowTypo: false,
495
+ threshold: -1e4
496
+ };
497
+ // Normalize text by trimming whitespace, converting to lowercase, and removing diacritics.
498
+ // This ensures consistent matching/comparison of dropdown items.
499
+ const fuzzyResults = fuzzysort.go(normalizeText(inputQuery), miDropdownItemTexts, searchResultsOptions);
500
+ const filteredItems = fuzzyResults.map(result => this.items.find(item => (normalizeText(item.text) || normalizeText(item.innerText)) === normalizeText(result.target)));
501
+ this.currentItems = filteredItems;
502
+ if (numberOfItemsDisplayed !== this.currentItems.length) {
503
+ this.currentItemIndex = 0;
504
+ }
505
+ }
506
+ }
507
+ /**
508
+ * Clear filter.
509
+ */
510
+ async clearFilter() {
511
+ if (this.filterElement) {
512
+ this.filterElement.value = '';
513
+ this.filterElement.focus();
514
+ this.currentItems = this.items;
515
+ this.cleared.emit();
326
516
  }
327
- this.toggleContentWindow();
328
- this.clearFilter();
329
- }
330
- });
331
- }
332
- /**
333
- * Updates the currently highlighted item in the markup.
334
- *
335
- * @param {number} itemIndex
336
- */
337
- highlightItem(itemIndex, scrollIntoView = false) {
338
- var _a, _b;
339
- const items = this.hostElement.shadowRoot.querySelectorAll('.list__item');
340
- items.forEach(item => {
341
- item.classList.remove(this.highlightedItemClassName);
342
- });
343
- (_a = items[itemIndex]) === null || _a === void 0 ? void 0 : _a.classList.add(this.highlightedItemClassName);
344
- if (scrollIntoView) {
345
- (_b = items[itemIndex]) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest', inline: 'nearest' });
346
- }
347
- }
348
- /**
349
- * Get sorted items.
350
- * The sorting order is defined by the itemsOrder attribute.
351
- *
352
- * @param {HTMLMiDropdownItemElement[]} items
353
- * @returns {HTMLMiDropdownItemElement[]}
354
- */
355
- getSortedItems(items) {
356
- if (this.itemsOrder === SortOrder.Asc) {
357
- // Ascending order
358
- items.sort((a, b) => (a.text || a.innerText)
359
- .trimStart()
360
- .toLowerCase()
361
- .localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
362
- }
363
- else {
364
- // Descending order
365
- items.sort((b, a) => (a.text || a.innerText)
366
- .trimStart()
367
- .toLowerCase()
368
- .localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
369
- }
370
- return items;
371
- }
372
- /**
373
- * Update and emit list of selected items.
374
- */
375
- onChangedHandler() {
376
- this.selected = [...this.items.filter(item => item.selected)];
377
- this.change.emit(this.selected);
378
- }
379
- /**
380
- * Toggle visibility of content window.
381
- */
382
- toggleContentWindow() {
383
- this.open = !this.open;
384
- }
385
- /**
386
- * Check all checkboxes.
387
- */
388
- selectAll() {
389
- const items = Array.from(this.currentItems);
390
- for (const item of items) {
391
- item.selected = (`${item.dataset.excludefromall}` === 'true' || item.disabled) ? false : true;
392
- }
393
- this.onChangedHandler();
394
- }
395
- /**
396
- * Uncheck all checkboxes.
397
- */
398
- selectNone() {
399
- const items = Array.from(this.currentItems);
400
- for (const item of items) {
401
- item.selected = false;
402
- }
403
- this.onChangedHandler();
404
- }
405
- /**
406
- * Select or toggle selection of item.
407
- *
408
- * @param {HTMLMiDropdownItemElement} item
409
- */
410
- onSelect(item) {
411
- if (!this.multiple) {
412
- this.open = false;
413
- const items = Array.from(this.items);
414
- items.forEach((item) => { item.selected = false; });
415
- this.clearFilter();
416
- }
417
- item.selected = !item.selected;
418
- this.currentItemIndex = Number(item.dataset.index);
419
- this.selectedItemIndex = this.currentItemIndex;
420
- this.onChangedHandler();
421
- }
422
- /**
423
- * Highlights the item that the cursor is hovering in the content window.
424
- *
425
- * @param {number} filteredItemsIndex
426
- */
427
- onMouseOver(filteredItemsIndex) {
428
- if (!this.isMouseOverEventDisabled && !this.multiple) {
429
- this.highlightItem(filteredItemsIndex);
430
- this.currentItemIndex = filteredItemsIndex;
431
- }
432
- }
433
- /**
434
- * Filter items based on the input query.
435
- */
436
- filter() {
437
- if (this.filterElement) {
438
- const inputQuery = this.filterElement.value;
439
- // Normalize text by trimming whitespace, converting to lowercase, and removing diacritics.
440
- // This ensures consistent matching/comparison of dropdown items.
441
- const miDropdownItemTexts = this.items.map(item => (normalizeText(item.text) || normalizeText(item.innerText)));
442
- const numberOfItemsDisplayed = this.currentItems.length;
443
- if (inputQuery === '') {
444
- this.currentItemIndex = this.selectedItemIndex;
445
517
  this.isClearButtonVisible = false;
446
- this.currentItems = [...this.items];
447
- return;
448
- }
449
- else {
450
- this.isClearButtonVisible = true;
451
- }
452
- const searchResultsOptions = {
453
- limit: 50,
454
- allowTypo: false,
455
- threshold: -10000
456
- };
457
- // Normalize text by trimming whitespace, converting to lowercase, and removing diacritics.
458
- // This ensures consistent matching/comparison of dropdown items.
459
- const fuzzyResults = fuzzysort.go(normalizeText(inputQuery), miDropdownItemTexts, searchResultsOptions);
460
- const filteredItems = fuzzyResults.map(result => this.items.find(item => (normalizeText(item.text) || normalizeText(item.innerText)) === normalizeText(result.target)));
461
- this.currentItems = filteredItems;
462
- if (numberOfItemsDisplayed !== this.currentItems.length) {
463
- this.currentItemIndex = 0;
464
- }
465
- }
466
- }
467
- /**
468
- * Clear filter.
469
- */
470
- clearFilter() {
471
- if (this.filterElement) {
472
- this.filterElement.value = '';
473
- this.filterElement.focus();
474
- this.currentItems = this.items;
475
- this.cleared.emit();
476
- }
477
- this.isClearButtonVisible = false;
478
- }
479
- /**
480
- * Render the dropdown component.
481
- *
482
- * @returns {JSX.Element}
483
- */
484
- render() {
485
- const filter = this.filterable ? this.renderFiltering() : null;
486
- const multiple = this.multiple ? this.renderMultipleOptions() : null;
487
- const leftSideIcon = this.iconSrc ? this.renderLeftSideIcon() : null;
488
- const listOfItems = (h("ul", { class: "list" }, this.currentItems.map((item, index) => this.renderListItem(item, index, (multiple ? true : false)))));
489
- return (h(Host, { class: { 'open': this.open } }, h("button", { part: "button", class: "button", disabled: this.disabled || this.items.length === 0, onClick: () => this.toggleContentWindow() }, leftSideIcon, this.renderButtonLabel(), h("svg", { class: "arrow", part: "icon-down-arrow", width: "12", height: "6", viewBox: "0 0 18 10", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M9.37165 9.58706C9.17303 9.80775 8.82697 9.80775 8.62835 9.58706L0.751035 0.834484C0.46145 0.512722 0.689796 7.73699e-08 1.12268 1.25924e-07L16.8773 1.89302e-06C17.3102 1.94157e-06 17.5386 0.512723 17.249 0.834484L9.37165 9.58706Z" }))), h("section", { ref: (el) => this.listElement = el, part: "dropdown-container", class: "content", "tab-index": "1" }, filter, multiple, this.currentItems.length === 0 ? this.renderNoResultsTemplate() : listOfItems)));
490
- }
491
- /**
492
- * Helper function to render markup when no items are available to be displayed in the content window.
493
- *
494
- * @returns {JSX.Element}
495
- */
496
- renderNoResultsTemplate() {
497
- const noResultsTemplate = (h("div", { class: "empty-page" }, h("p", { class: "empty-page__header" }, this.noResultsMessage)));
498
- return noResultsTemplate;
499
- }
500
- /**
501
- * Helper function to render the button label.
502
- *
503
- * @returns {JSX.Element}
504
- */
505
- renderButtonLabel() {
506
- var _a, _b, _c, _d, _e;
507
- const label = (_a = this.label) !== null && _a !== void 0 ? _a : (_c = (_b = this.selected) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.text;
508
- if (label > '') {
509
- return (h("div", { part: "button-label", class: "button__label" }, label));
510
- }
511
- else if ((_e = (_d = this.selected) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.innerHTML) {
512
- return (h("div", { part: "button-label", class: "button__label button__label--from-inner-html", innerHTML: this.selected[0].innerHTML }));
513
- }
514
- else {
515
- return (h("div", { part: "button-label", class: "button__label" }));
516
- }
517
- }
518
- /**
519
- * Helper function to render an icon when an image source is provided.
520
- *
521
- * @returns {JSX.Element}
522
- */
523
- renderLeftSideIcon() {
524
- return (h("img", { part: "button-icon", class: "button__left-icon", src: this.iconSrc, alt: this.iconAlt ? this.iconAlt : '' }));
525
- }
526
- /**
527
- * Helper function for rendering the filtering UI.
528
- *
529
- * @returns {JSX.Element}
530
- */
531
- renderFiltering() {
532
- return (h("div", { class: "filter" }, h("input", { type: "text", class: "mi-input filter__input", placeholder: this.placeholder, ref: (el) => this.filterElement = el, onInput: () => { this.filter(); }, tabIndex: this.open ? 0 : -1 }), h("button", { ref: (el) => this.clearButtonElement = el, tabindex: this.isClearButtonVisible ? 0 : -1, type: "button", onClick: () => this.clearFilter(), class: `filter__clear ${this.isClearButtonVisible === false ? 'filter__clear--hidden' : ''}`, "aria-label": "Clear" }, h("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" })))));
533
- }
534
- /**
535
- * Helper function for rendering the multi select options.
536
- *
537
- * @returns {JSX.Element}
538
- */
539
- renderMultipleOptions() {
540
- return (h("div", { class: "options" }, h("button", { class: "options__item", disabled: this.isFilterSelectionDisabled, onClick: () => this.selectAll() }, "Select all"), h("button", { class: "options__item", disabled: this.isFilterSelectionDisabled, onClick: () => this.selectNone() }, "Select none")));
541
- }
542
- /**
543
- * Helper function for rendering list item.
544
- *
545
- * @param {HTMLMiDropdownItemElement} item
546
- * @param {number} index
547
- * @param {boolean} showCheckBox
548
- * @returns {JSX.Element}
549
- */
550
- renderListItem(item, index, showCheckBox) {
551
- let itemText;
552
- const itemTooltipInfo = (item.getAttribute('title') || item.text || item.innerText);
553
- if (item.innerText.length > 0) {
554
- itemText = h("div", { class: "label__item label__item--from-inner-html", innerHTML: item.innerHTML });
555
- }
556
- else {
557
- itemText = h("div", { class: "label__item", innerHTML: item.text });
558
- }
559
- return (h("li", { class: { 'list__item': true, 'list__item--disabled': item.disabled }, title: itemTooltipInfo, onMouseOver: () => { this.onMouseOver(index); } }, h("label", { class: "mi-label label", tabindex: "-1" }, h("input", { class: { 'label__checkbox': true, 'label__checkbox--hidden': !showCheckBox, 'mi-input': true }, type: "checkbox", value: index, checked: item.selected, disabled: item.disabled, "data-excludefromall": item.excludefromall, onChange: () => this.onSelect(item) }), itemText)));
560
- }
561
- /**
562
- * Function for calculating the position of the dropdown list element.
563
- */
564
- calculateDropDownPosition() {
565
- this.listElement.style.bottom = null;
566
- this.listElement.style.left = null;
567
- this.listElement.style.right = null;
568
- this.listElement.style.top = null;
569
- this.listElement.style.maxHeight = null;
570
- this.listElement.style.minWidth = null;
571
- const { clientWidth, clientHeight } = document.documentElement;
572
- const hostElementRect = this.hostElement.getBoundingClientRect();
573
- const listElementRect = this.listElement.getBoundingClientRect();
574
- const availableSpaceBelowComponent = clientHeight - hostElementRect.bottom;
575
- const availableSpaceAboveComponent = hostElementRect.top;
576
- const MAX_HEIGHT = 580;
577
- const MARGIN = 12;
578
- if (clientWidth <= listElementRect.width || (hostElementRect.right - listElementRect.width < 0 && listElementRect.right > clientWidth)) {
579
- this.listElement.style.right = `${MARGIN}px`;
580
- this.listElement.style.left = `${MARGIN}px`;
581
- this.listElement.style.minWidth = 'unset';
582
- }
583
- else if (listElementRect.right > clientWidth || this.dropdownAlignment === 'right') {
584
- this.listElement.style.left = 'unset';
585
- this.listElement.style.right = `${clientWidth - hostElementRect.right}px`;
586
- }
587
- else {
588
- this.listElement.style.left = `${hostElementRect.left}px`;
589
- this.listElement.style.right = 'unset';
590
- }
591
- if (availableSpaceAboveComponent > availableSpaceBelowComponent) {
592
- this.listElement.style.maxHeight = `${Math.min(availableSpaceAboveComponent, MAX_HEIGHT)}px`;
593
- this.listElement.style.top = 'unset';
594
- this.listElement.style.bottom = `${clientHeight - hostElementRect.top}px`;
595
- }
596
- else {
597
- this.listElement.style.top = `${hostElementRect.bottom}px`;
598
- this.listElement.style.bottom = 'unset';
599
- this.listElement.style.maxHeight = `${Math.min(availableSpaceBelowComponent - (MARGIN * 2), MAX_HEIGHT)}px`;
600
- }
601
- }
602
- get hostElement() { return getElement(this); }
603
- static get watchers() { return {
604
- "items": ["onItemsChanged"],
605
- "currentItems": ["onCurrentItemsChange"]
606
- }; }
518
+ }
519
+ /**
520
+ * Render the dropdown component.
521
+ *
522
+ * @returns {JSX.Element}
523
+ */
524
+ render() {
525
+ const filter = this.filterable ? this.renderFiltering() : null;
526
+ const multiple = this.multiple ? this.renderMultipleOptions() : null;
527
+ const leftSideIcon = this.iconSrc ? this.renderLeftSideIcon() : null;
528
+ const listOfItems = (h("ul", { key: 'ff19a6a97fca88aedd028fab4bd5980374f91c95', class: "list" }, this.currentItems.map((item, index) => this.renderListItem(item, index, (multiple ? true : false)))));
529
+ return (h(Host, { key: 'c6b2f66e22e532a6b28c95e7715ba58f0fac0ca6', class: { 'open': this.open } }, h("button", { key: '8fc5ea12d4a02d434aea1b78717002a1be34debe', part: "button", class: "button", disabled: this.disabled || this.items.length === 0, onClick: () => this.toggleContentWindow() }, leftSideIcon, this.renderButtonLabel(), h("svg", { key: '8b6f271f89242ab40c16ef149a40dd0fde9ba08c', class: "arrow", part: "icon-down-arrow", width: "12", height: "6", viewBox: "0 0 18 10", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '127e71c1bfc6cb5c2f3deac9f54fa3b95cfea612', d: "M9.37165 9.58706C9.17303 9.80775 8.82697 9.80775 8.62835 9.58706L0.751035 0.834484C0.46145 0.512722 0.689796 7.73699e-08 1.12268 1.25924e-07L16.8773 1.89302e-06C17.3102 1.94157e-06 17.5386 0.512723 17.249 0.834484L9.37165 9.58706Z" }))), h("section", { key: '90ba4cb1f24f80073f469da9967f4b413098f892', ref: (el) => this.listElement = el, part: "dropdown-container", class: "content", "tab-index": "1" }, filter, multiple, this.currentItems.length === 0 ? this.renderNoResultsTemplate() : listOfItems)));
530
+ }
531
+ /**
532
+ * Helper function to render markup when no items are available to be displayed in the content window.
533
+ *
534
+ * @returns {JSX.Element}
535
+ */
536
+ renderNoResultsTemplate() {
537
+ const noResultsTemplate = (h("div", { class: "empty-page" }, h("p", { class: "empty-page__header" }, this.noResultsMessage)));
538
+ return noResultsTemplate;
539
+ }
540
+ /**
541
+ * Helper function to render the button label.
542
+ *
543
+ * @returns {JSX.Element}
544
+ */
545
+ renderButtonLabel() {
546
+ var _a, _b, _c, _d, _e;
547
+ const label = (_a = this.label) !== null && _a !== void 0 ? _a : (_c = (_b = this.selected) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.text;
548
+ if (label > '') {
549
+ return (h("div", { part: "button-label", class: "button__label" }, label));
550
+ }
551
+ else if ((_e = (_d = this.selected) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.innerHTML) {
552
+ return (h("div", { part: "button-label", class: "button__label button__label--from-inner-html", innerHTML: this.selected[0].innerHTML }));
553
+ }
554
+ else {
555
+ return (h("div", { part: "button-label", class: "button__label" }));
556
+ }
557
+ }
558
+ /**
559
+ * Helper function to render an icon when an image source is provided.
560
+ *
561
+ * @returns {JSX.Element}
562
+ */
563
+ renderLeftSideIcon() {
564
+ return (h("img", { part: "button-icon", class: "button__left-icon", src: this.iconSrc, alt: this.iconAlt ? this.iconAlt : '' }));
565
+ }
566
+ /**
567
+ * Helper function for rendering the filtering UI.
568
+ *
569
+ * @returns {JSX.Element}
570
+ */
571
+ renderFiltering() {
572
+ return (h("div", { class: "filter" }, h("input", { type: "text", class: "mi-input filter__input", placeholder: this.placeholder, ref: (el) => this.filterElement = el, onInput: () => { this.filter(); }, tabIndex: this.open ? 0 : -1 }), h("button", { ref: (el) => this.clearButtonElement = el, tabindex: this.isClearButtonVisible ? 0 : -1, type: "button", onClick: () => this.clearFilter(), class: `filter__clear ${this.isClearButtonVisible === false ? 'filter__clear--hidden' : ''}`, "aria-label": "Clear" }, h("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" })))));
573
+ }
574
+ /**
575
+ * Helper function for rendering the multi select options.
576
+ *
577
+ * @returns {JSX.Element}
578
+ */
579
+ renderMultipleOptions() {
580
+ return (h("div", { class: "options" }, h("button", { class: "options__item", disabled: this.isFilterSelectionDisabled, onClick: () => this.selectAll() }, "Select all"), h("button", { class: "options__item", disabled: this.isFilterSelectionDisabled, onClick: () => this.selectNone() }, "Select none")));
581
+ }
582
+ /**
583
+ * Helper function for rendering list item.
584
+ *
585
+ * @param {HTMLMiDropdownItemElement} item
586
+ * @param {number} index
587
+ * @param {boolean} showCheckBox
588
+ * @returns {JSX.Element}
589
+ */
590
+ renderListItem(item, index, showCheckBox) {
591
+ let itemText;
592
+ const itemTooltipInfo = (item.getAttribute('title') || item.text || item.innerText);
593
+ if (item.innerText.length > 0) {
594
+ itemText = h("div", { class: "label__item label__item--from-inner-html", innerHTML: item.innerHTML });
595
+ }
596
+ else {
597
+ itemText = h("div", { class: "label__item", innerHTML: item.text });
598
+ }
599
+ return (h("li", { class: { 'list__item': true, 'list__item--disabled': item.disabled }, title: itemTooltipInfo, onMouseOver: () => { this.onMouseOver(index); } }, h("label", { class: "mi-label label", tabindex: "-1" }, h("input", { class: { 'label__checkbox': true, 'label__checkbox--hidden': !showCheckBox, 'mi-input': true }, type: "checkbox", value: index, checked: item.selected, disabled: item.disabled, "data-excludefromall": item.excludefromall, onChange: () => this.onSelect(item) }), itemText)));
600
+ }
601
+ /**
602
+ * Function for calculating the position of the dropdown list element.
603
+ */
604
+ calculateDropDownPosition() {
605
+ this.listElement.style.bottom = null;
606
+ this.listElement.style.left = null;
607
+ this.listElement.style.right = null;
608
+ this.listElement.style.top = null;
609
+ this.listElement.style.maxHeight = null;
610
+ this.listElement.style.minWidth = null;
611
+ const { clientWidth, clientHeight } = document.documentElement;
612
+ const hostElementRect = this.hostElement.getBoundingClientRect();
613
+ const listElementRect = this.listElement.getBoundingClientRect();
614
+ const availableSpaceBelowComponent = clientHeight - hostElementRect.bottom;
615
+ const availableSpaceAboveComponent = hostElementRect.top;
616
+ const MAX_HEIGHT = 580;
617
+ const MARGIN = 12;
618
+ if (clientWidth <= listElementRect.width || (hostElementRect.right - listElementRect.width < 0 && listElementRect.right > clientWidth)) {
619
+ this.listElement.style.right = `${MARGIN}px`;
620
+ this.listElement.style.left = `${MARGIN}px`;
621
+ this.listElement.style.minWidth = 'unset';
622
+ }
623
+ else if (listElementRect.right > clientWidth || this.dropdownAlignment === 'right') {
624
+ this.listElement.style.left = 'unset';
625
+ this.listElement.style.right = `${clientWidth - hostElementRect.right}px`;
626
+ }
627
+ else {
628
+ this.listElement.style.left = `${hostElementRect.left}px`;
629
+ this.listElement.style.right = 'unset';
630
+ }
631
+ if (availableSpaceAboveComponent > availableSpaceBelowComponent) {
632
+ this.listElement.style.maxHeight = `${Math.min(availableSpaceAboveComponent, MAX_HEIGHT)}px`;
633
+ this.listElement.style.top = 'unset';
634
+ this.listElement.style.bottom = `${clientHeight - hostElementRect.top}px`;
635
+ }
636
+ else {
637
+ this.listElement.style.top = `${hostElementRect.bottom}px`;
638
+ this.listElement.style.bottom = 'unset';
639
+ this.listElement.style.maxHeight = `${Math.min(availableSpaceBelowComponent - (MARGIN * 2), MAX_HEIGHT)}px`;
640
+ }
641
+ }
642
+ get hostElement() { return getElement(this); }
643
+ static get watchers() { return {
644
+ "items": [{
645
+ "onItemsChanged": 0
646
+ }],
647
+ "currentItems": [{
648
+ "onCurrentItemsChange": 0
649
+ }]
650
+ }; }
607
651
  };
608
- Dropdown.style = dropdownCss;
652
+ Dropdown.style = dropdownCss();
609
653
 
610
654
  export { Dropdown as mi_dropdown };