@mapsindoors/map-template 1.95.0 → 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.
- package/dist/{GoogleMapsMap-BIUan6Mh.mjs → GoogleMapsMap-Dkn60-_e.mjs} +2 -2
- package/dist/{MapboxMap-BwTFmd5b.mjs → MapboxMap-B1oo7IUm.mjs} +3 -3
- package/dist/_commonjsHelpers-B85MJLTf.js +5 -0
- package/dist/app-globals-DQuL1Twl.js +3 -0
- package/dist/combo-box-item.entry.js +8 -10
- package/dist/icon-DT_sDkmK.js +11 -0
- package/dist/index-BZQHyS7V.js +1701 -0
- package/dist/loader.js +7 -14
- package/dist/mapsindoors-react.es.js +1 -1
- package/dist/mapsindoors-react.umd.js +175 -175
- package/dist/mapsindoors-webcomponent.es.js +2919 -2907
- package/dist/mi-card_2.entry.js +23 -18
- package/dist/mi-chip.entry.js +25 -16
- package/dist/mi-column.entry.js +47 -23
- package/dist/mi-combo-box.entry.js +412 -379
- package/dist/mi-components.js +15 -12
- package/dist/mi-data-table.entry.js +298 -278
- package/dist/mi-distance_2.entry.js +58 -56
- package/dist/mi-dropdown-item.entry.js +8 -10
- package/dist/mi-dropdown.entry.js +525 -481
- package/dist/mi-floor-selector.entry.js +183 -180
- package/dist/mi-keyboard.entry.js +207 -186
- package/dist/mi-list-item-category.entry.js +44 -41
- package/dist/mi-list-item-location.entry.js +168 -162
- package/dist/mi-list.entry.js +56 -48
- package/dist/mi-location-booking.entry.js +320 -295
- package/dist/mi-location-info.entry.js +61 -53
- package/dist/mi-map-googlemaps.entry.js +369 -324
- package/dist/mi-map-mapbox.entry.js +502 -439
- package/dist/mi-metric-card.entry.js +50 -37
- package/dist/mi-my-position.entry.js +2341 -874
- package/dist/mi-notification.entry.js +112 -102
- package/dist/mi-route-instructions-heading.entry.js +70 -65
- package/dist/mi-route-instructions-maneuver-legacy.entry.js +80 -76
- package/dist/mi-route-instructions-maneuver.entry.js +80 -76
- package/dist/mi-route-instructions-step-legacy.entry.js +296 -282
- package/dist/mi-route-instructions-step.entry.js +313 -292
- package/dist/mi-route-instructions.entry.js +167 -150
- package/dist/mi-scroll-buttons.entry.js +104 -98
- package/dist/mi-search.entry.js +366 -325
- package/dist/mi-share-sms.entry.js +82 -70
- package/dist/mi-step-switcher.entry.js +34 -25
- package/dist/mi-tab-panel.entry.js +18 -18
- package/dist/mi-tab.entry.js +5 -7
- package/dist/mi-tabs.entry.js +42 -40
- package/dist/mi-time.entry.js +49 -49
- package/dist/mi-variables-CDNvnTkH.js +5 -0
- package/dist/{reactcomponent-D3K1zzGs.mjs → reactcomponent-2Oa1vSiK.mjs} +8996 -8660
- package/dist/route-travel-mode.enum-BvqP1fpw.js +9 -0
- package/dist/sort-order.enum-jsLAbYWg.js +566 -0
- package/dist/{unit-system.enum-eaefb53e.js → unit-system.enum-BwPgAWqL.js} +2 -2
- package/dist/utils-DNHzysQ6.js +61 -0
- package/package.json +1 -1
- package/dist/_commonjsHelpers-ba3f0406.js +0 -21
- package/dist/icon-b8d01d6f.js +0 -24
- package/dist/index-7e9696f3.js +0 -1678
- package/dist/mi-variables-9a6c8d4d.js +0 -6
- package/dist/polyfills/core-js.js +0 -11
- package/dist/polyfills/css-shim.js +0 -1
- package/dist/polyfills/dom.js +0 -79
- package/dist/polyfills/es5-html-element.js +0 -1
- package/dist/polyfills/index.js +0 -34
- package/dist/polyfills/system.js +0 -6
- package/dist/route-travel-mode.enum-7f4ce9c7.js +0 -9
- package/dist/sort-order.enum-64ce8998.js +0 -552
- package/dist/utils-ae714467.js +0 -61
|
@@ -1,416 +1,449 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-
|
|
2
|
-
import { S as SortOrder, f as fuzzysort } from './sort-order.enum-
|
|
3
|
-
import './_commonjsHelpers-
|
|
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
|
-
const comboBoxCss =
|
|
5
|
+
const comboBoxCss = () => `.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}combo-box-item{display:none}:host{display:inline-block;position:relative;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{transform:rotate(180deg)}.input{position:relative;display:flex;justify-content:flex-start;align-items:center;height:100%;width:100%;font-family:inherit;background:linear-gradient(#f9fafb, #f3f4f6);border-radius:4px;border-width:1px;border-style:solid;border-color:#d1d5db;color:#1c1917;font-size:1rem;font-weight:500;line-height:1rem;padding-right:40px;padding-left:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.input__svg{margin-left:auto;position:absolute;top:50%;right:-42px}.input__label{padding-top:12px;padding-bottom:12px;margin-right:8px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.input__label--from-inner-html{display:flex;flex-direction:row;align-items:center;gap:8px}.input: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 .list{padding:0;margin:0;list-style:none;overflow-y:auto}.content .list__item{cursor:pointer}.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:flex;flex-direction:row;align-items:center;gap:8px}.label__checkbox{margin-right:12px}.label__checkbox--hidden{display:none}`;
|
|
6
6
|
|
|
7
7
|
var KeyCode;
|
|
8
8
|
(function (KeyCode) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
KeyCode["ArrowDown"] = "ArrowDown";
|
|
10
|
+
KeyCode["ArrowUp"] = "ArrowUp";
|
|
11
|
+
KeyCode["Enter"] = "Enter";
|
|
12
|
+
KeyCode["Esc"] = "Escape";
|
|
13
13
|
})(KeyCode || (KeyCode = {}));
|
|
14
14
|
const ComboBox = class {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
constructor(hostRef) {
|
|
16
|
+
registerInstance(this, hostRef);
|
|
17
|
+
this.change = createEvent(this, "change", 3);
|
|
18
|
+
/**
|
|
19
|
+
* Gets or sets the state of the dropdown.
|
|
20
|
+
* If the attribute is set to true then the dropdown will be expanded.
|
|
21
|
+
*
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
*/
|
|
24
|
+
this.open = false;
|
|
25
|
+
/**
|
|
26
|
+
* Gets or sets the list items.
|
|
27
|
+
*
|
|
28
|
+
* @type {Array<HTMLMiDropdownItemElement>}
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
this.items = [];
|
|
32
|
+
/**
|
|
33
|
+
* This attribute indicates that the items can be filtered using the input field present at the top.
|
|
34
|
+
* If it is not specified, the input field will not be visible, and filtering is not possible.
|
|
35
|
+
*
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
this.filterable = false;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the selected items.
|
|
41
|
+
*
|
|
42
|
+
* @type {Array<HTMLMiDropdownItemElement>}
|
|
43
|
+
*/
|
|
44
|
+
this.selected = [];
|
|
45
|
+
/**
|
|
46
|
+
* Guiding message when presented with a content window that has no rows.
|
|
47
|
+
* Default language is English.
|
|
48
|
+
*/
|
|
49
|
+
this.noResultsMessage = 'No results found';
|
|
50
|
+
this.currentItems = [];
|
|
51
|
+
/**
|
|
52
|
+
* Sets the disabled state for the dropdown.
|
|
53
|
+
*/
|
|
54
|
+
this.disabled = false;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the disabled state of the select buttons in the filterable version of the component.
|
|
57
|
+
*/
|
|
58
|
+
this.isFilterSelectionDisabled = false;
|
|
59
|
+
/**
|
|
60
|
+
* Flag to control the mouseover event on the items. The event is disabled when using the arrow keys to navigate the list.
|
|
61
|
+
*/
|
|
62
|
+
this.isMouseOverEventDisabled = false;
|
|
63
|
+
this.currentItemIndex = 0;
|
|
64
|
+
this.selectedItemIndex = 0;
|
|
65
|
+
this.highlightedItemClassName = 'list__item--highlighted';
|
|
66
|
+
}
|
|
67
|
+
onItemsChanged(items) {
|
|
68
|
+
if (items.some(item => item.tagName.toLowerCase() !== 'combo-box-item')) {
|
|
69
|
+
throw new Error('Items contains unknown element(s).');
|
|
70
|
+
}
|
|
71
|
+
if (Object.values(SortOrder).includes(this.itemsOrder)) {
|
|
72
|
+
items = this.getSortedItems(items);
|
|
73
|
+
}
|
|
74
|
+
this.currentItems = [...items];
|
|
75
|
+
this.filter();
|
|
76
|
+
if (!this.filterable) {
|
|
77
|
+
const selectedItemIndex = this.currentItems.findIndex(item => item.selected);
|
|
78
|
+
this.currentItemIndex = selectedItemIndex > -1 ? selectedItemIndex : 0;
|
|
79
|
+
this.selectedItemIndex = this.currentItemIndex;
|
|
80
|
+
}
|
|
81
|
+
this.items.forEach((item, itemIndex) => {
|
|
82
|
+
item.dataset.index = itemIndex.toString();
|
|
83
|
+
});
|
|
84
|
+
this.selectFirstMiDropdownItem();
|
|
85
|
+
}
|
|
86
|
+
onCurrentItemsChange() {
|
|
87
|
+
this.isFilterSelectionDisabled = this.currentItems.length === 0;
|
|
88
|
+
}
|
|
18
89
|
/**
|
|
19
|
-
*
|
|
90
|
+
* Outside the dropdown listener. It will close the dropdown when a click is outside a dropdown and dropdown list.
|
|
91
|
+
*
|
|
92
|
+
* @param {ev} ev
|
|
20
93
|
*/
|
|
21
|
-
|
|
94
|
+
checkForClickOutside(ev) {
|
|
95
|
+
var _a;
|
|
96
|
+
if (!this.hostElement.contains(ev.target) && this.noResultsMessage) {
|
|
97
|
+
this.clearFilter();
|
|
98
|
+
this.filterElement.value = (_a = this.selected[0]) === null || _a === void 0 ? void 0 : _a.text;
|
|
99
|
+
this.open = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
22
102
|
/**
|
|
23
|
-
*
|
|
103
|
+
* When clicked on input button we change it's type to text and highlight value that is inside.
|
|
104
|
+
*
|
|
105
|
+
* @param {Event} event
|
|
24
106
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.open = false;
|
|
30
|
-
this.items = [];
|
|
31
|
-
this.itemsOrder = undefined;
|
|
32
|
-
this.filterable = false;
|
|
33
|
-
this.selected = [];
|
|
34
|
-
this.noResultsMessage = 'No results found';
|
|
35
|
-
this.currentItems = [];
|
|
36
|
-
this.disabled = false;
|
|
37
|
-
}
|
|
38
|
-
onItemsChanged(items) {
|
|
39
|
-
if (items.some(item => item.tagName.toLowerCase() !== 'combo-box-item')) {
|
|
40
|
-
throw new Error('Items contains unknown element(s).');
|
|
41
|
-
}
|
|
42
|
-
if (Object.values(SortOrder).includes(this.itemsOrder)) {
|
|
43
|
-
items = this.getSortedItems(items);
|
|
107
|
+
onClickExists(event) {
|
|
108
|
+
this.open = true;
|
|
109
|
+
event.target.type = 'text';
|
|
110
|
+
this.filterElement.select();
|
|
44
111
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
this.items.forEach((item, itemIndex) => {
|
|
53
|
-
item.dataset.index = itemIndex.toString();
|
|
54
|
-
});
|
|
55
|
-
this.selectFirstMiDropdownItem();
|
|
56
|
-
}
|
|
57
|
-
onCurrentItemsChange() {
|
|
58
|
-
this.isFilterSelectionDisabled = this.currentItems.length === 0;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Outside the dropdown listener. It will close the dropdown when a click is outside a dropdown and dropdown list.
|
|
62
|
-
*
|
|
63
|
-
* @param {ev} ev
|
|
64
|
-
*/
|
|
65
|
-
checkForClickOutside(ev) {
|
|
66
|
-
var _a;
|
|
67
|
-
if (!this.hostElement.contains(ev.target) && this.noResultsMessage) {
|
|
68
|
-
this.clearFilter();
|
|
69
|
-
this.filterElement.value = (_a = this.selected[0]) === null || _a === void 0 ? void 0 : _a.text;
|
|
70
|
-
this.open = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* When clicked on input button we change it's type to text and highlight value that is inside.
|
|
75
|
-
*
|
|
76
|
-
* @param {Event} event
|
|
77
|
-
*/
|
|
78
|
-
onClickExists(event) {
|
|
79
|
-
this.open = true;
|
|
80
|
-
event.target.type = 'text';
|
|
81
|
-
this.filterElement.select();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Mousemove event handler.
|
|
85
|
-
* When the mouse is moved the mouseover event handler is enabled.
|
|
86
|
-
*/
|
|
87
|
-
mouseMoveEventHandler() {
|
|
88
|
-
this.isMouseOverEventDisabled = false;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Scroll event handler.
|
|
92
|
-
* The dropdown is closed when the scroll event is trigget outside the dropdown.
|
|
93
|
-
*/
|
|
94
|
-
scrollEventHandler(event) {
|
|
95
|
-
const target = event.target;
|
|
96
|
-
if (!target || !this.hostElement.contains(target)) {
|
|
97
|
-
this.open = false;
|
|
112
|
+
/**
|
|
113
|
+
* Mousemove event handler.
|
|
114
|
+
* When the mouse is moved the mouseover event handler is enabled.
|
|
115
|
+
*/
|
|
116
|
+
mouseMoveEventHandler() {
|
|
117
|
+
this.isMouseOverEventDisabled = false;
|
|
98
118
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Component did load.
|
|
109
|
-
*/
|
|
110
|
-
componentDidLoad() {
|
|
111
|
-
this.createMiDropdownItemsFromDocument();
|
|
112
|
-
this.selectFirstMiDropdownItem();
|
|
113
|
-
this.enableKeyboardNavigationEvents();
|
|
114
|
-
const filterElementObserver = new IntersectionObserver((entries) => {
|
|
115
|
-
entries.forEach(entry => {
|
|
116
|
-
if (entry.isIntersecting === true) {
|
|
117
|
-
this.filterElement.blur();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
if (this.filterElement !== undefined) {
|
|
122
|
-
filterElementObserver.observe(this.filterElement);
|
|
123
|
-
this.filterElement.addEventListener('keydown', (event) => {
|
|
124
|
-
if (event.key === KeyCode.ArrowDown || event.key === KeyCode.ArrowUp) {
|
|
125
|
-
event.preventDefault();
|
|
119
|
+
/**
|
|
120
|
+
* Scroll event handler.
|
|
121
|
+
* The dropdown is closed when the scroll event is trigget outside the dropdown.
|
|
122
|
+
*/
|
|
123
|
+
scrollEventHandler(event) {
|
|
124
|
+
const target = event.target;
|
|
125
|
+
if (!target || !this.hostElement.contains(target)) {
|
|
126
|
+
this.open = false;
|
|
126
127
|
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Component did rener.
|
|
132
|
-
*/
|
|
133
|
-
componentDidRender() {
|
|
134
|
-
this.calculateDropDownPosition();
|
|
135
|
-
if (!this.filterable) {
|
|
136
|
-
// Makes sure that an item is always highlighted when the content window is open.
|
|
137
|
-
this.highlightItem(this.currentItemIndex, true);
|
|
138
128
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (items.length > 0) {
|
|
146
|
-
this.items = Array.from(items);
|
|
129
|
+
/**
|
|
130
|
+
* Resize event handler.
|
|
131
|
+
* Recalculate the position of the dropdown when the window is resized.
|
|
132
|
+
*/
|
|
133
|
+
resizeEventHandler() {
|
|
134
|
+
this.calculateDropDownPosition();
|
|
147
135
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Component did load.
|
|
138
|
+
*/
|
|
139
|
+
componentDidLoad() {
|
|
140
|
+
this.createMiDropdownItemsFromDocument();
|
|
141
|
+
this.selectFirstMiDropdownItem();
|
|
142
|
+
this.enableKeyboardNavigationEvents();
|
|
143
|
+
const filterElementObserver = new IntersectionObserver((entries) => {
|
|
144
|
+
entries.forEach(entry => {
|
|
145
|
+
if (entry.isIntersecting === true) {
|
|
146
|
+
this.filterElement.blur();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
if (this.filterElement !== undefined) {
|
|
151
|
+
filterElementObserver.observe(this.filterElement);
|
|
152
|
+
this.filterElement.addEventListener('keydown', (event) => {
|
|
153
|
+
if (event.key === KeyCode.ArrowDown || event.key === KeyCode.ArrowUp) {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.isMouseOverEventDisabled = true;
|
|
166
|
-
this.toggleContentWindow();
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (this.open === true && !this.filterable) {
|
|
171
|
-
switch (event.key) {
|
|
172
|
-
case KeyCode.ArrowDown || KeyCode.ArrowUp:
|
|
173
|
-
this.isMouseOverEventDisabled = true;
|
|
174
|
-
this.currentItemIndex = (this.currentItemIndex + 1) % this.currentItems.length;
|
|
175
|
-
this.highlightItem(this.currentItemIndex, true);
|
|
176
|
-
event.preventDefault();
|
|
177
|
-
break;
|
|
178
|
-
case KeyCode.ArrowUp:
|
|
179
|
-
this.isMouseOverEventDisabled = true;
|
|
180
|
-
this.currentItemIndex = ((this.currentItemIndex + this.currentItems.length) - 1) % this.currentItems.length;
|
|
159
|
+
/**
|
|
160
|
+
* Component did rener.
|
|
161
|
+
*/
|
|
162
|
+
componentDidRender() {
|
|
163
|
+
this.calculateDropDownPosition();
|
|
164
|
+
if (!this.filterable) {
|
|
165
|
+
// Makes sure that an item is always highlighted when the content window is open.
|
|
181
166
|
this.highlightItem(this.currentItemIndex, true);
|
|
182
|
-
event.preventDefault();
|
|
183
|
-
break;
|
|
184
|
-
case KeyCode.Enter:
|
|
185
|
-
if (this.hostElement.shadowRoot.activeElement === this.clearButtonElement) {
|
|
186
|
-
// When the clear button is focused and Enter is pressed, don't select the
|
|
187
|
-
// currently highlighted item or close the content window.
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (this.currentItems[this.currentItemIndex] !== undefined) {
|
|
191
|
-
this.onSelect(this.currentItems[this.currentItemIndex]);
|
|
192
|
-
}
|
|
193
|
-
event.preventDefault();
|
|
194
|
-
break;
|
|
195
167
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Gets all mi-dropdown-item elements for the mi-dropdown items property.
|
|
171
|
+
*/
|
|
172
|
+
createMiDropdownItemsFromDocument() {
|
|
173
|
+
const items = this.items && this.items.length > 0 ? this.items : this.hostElement.querySelectorAll('combo-box-item');
|
|
174
|
+
if (items.length > 0) {
|
|
175
|
+
this.items = Array.from(items);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Set the first mi-dropdown-item as the textual content of the button.
|
|
180
|
+
*/
|
|
181
|
+
selectFirstMiDropdownItem() {
|
|
182
|
+
var _a;
|
|
199
183
|
if (!this.filterable) {
|
|
200
|
-
|
|
201
|
-
|
|
184
|
+
const selectedIndex = (_a = this.items) === null || _a === void 0 ? void 0 : _a.findIndex((item) => { return item.selected; });
|
|
185
|
+
this.selected = [this.items[selectedIndex > -1 ? selectedIndex : 0]];
|
|
202
186
|
}
|
|
203
|
-
this.toggleContentWindow();
|
|
204
|
-
this.clearFilter();
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Updates the currently highlighted item in the markup.
|
|
210
|
-
*
|
|
211
|
-
* @param {number} itemIndex
|
|
212
|
-
*/
|
|
213
|
-
highlightItem(itemIndex, scrollIntoView = false) {
|
|
214
|
-
var _a, _b;
|
|
215
|
-
const items = this.hostElement.shadowRoot.querySelectorAll('.list__item');
|
|
216
|
-
items.forEach(item => {
|
|
217
|
-
item.classList.remove(this.highlightedItemClassName);
|
|
218
|
-
});
|
|
219
|
-
(_a = items[itemIndex]) === null || _a === void 0 ? void 0 : _a.classList.add(this.highlightedItemClassName);
|
|
220
|
-
if (scrollIntoView) {
|
|
221
|
-
(_b = items[itemIndex]) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
222
187
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Enables cycling through the items in the content window using arrow up/down keys.
|
|
190
|
+
*/
|
|
191
|
+
enableKeyboardNavigationEvents() {
|
|
192
|
+
this.hostElement.addEventListener('keydown', event => {
|
|
193
|
+
if (this.open === false && event.key === KeyCode.ArrowDown) {
|
|
194
|
+
this.isMouseOverEventDisabled = true;
|
|
195
|
+
this.toggleContentWindow();
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (this.open === true && !this.filterable) {
|
|
200
|
+
switch (event.key) {
|
|
201
|
+
case KeyCode.ArrowDown || KeyCode.ArrowUp:
|
|
202
|
+
this.isMouseOverEventDisabled = true;
|
|
203
|
+
this.currentItemIndex = (this.currentItemIndex + 1) % this.currentItems.length;
|
|
204
|
+
this.highlightItem(this.currentItemIndex, true);
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
break;
|
|
207
|
+
case KeyCode.ArrowUp:
|
|
208
|
+
this.isMouseOverEventDisabled = true;
|
|
209
|
+
this.currentItemIndex = ((this.currentItemIndex + this.currentItems.length) - 1) % this.currentItems.length;
|
|
210
|
+
this.highlightItem(this.currentItemIndex, true);
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
break;
|
|
213
|
+
case KeyCode.Enter:
|
|
214
|
+
if (this.hostElement.shadowRoot.activeElement === this.clearButtonElement) {
|
|
215
|
+
// When the clear button is focused and Enter is pressed, don't select the
|
|
216
|
+
// currently highlighted item or close the content window.
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (this.currentItems[this.currentItemIndex] !== undefined) {
|
|
220
|
+
this.onSelect(this.currentItems[this.currentItemIndex]);
|
|
221
|
+
}
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// This case must be applied to all types of the dropdown component.
|
|
227
|
+
if (event.key === KeyCode.Esc) {
|
|
228
|
+
if (!this.filterable) {
|
|
229
|
+
this.currentItemIndex = this.selectedItemIndex;
|
|
230
|
+
this.highlightItem(this.currentItemIndex);
|
|
231
|
+
}
|
|
232
|
+
this.toggleContentWindow();
|
|
233
|
+
this.clearFilter();
|
|
234
|
+
}
|
|
235
|
+
});
|
|
238
236
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Updates the currently highlighted item in the markup.
|
|
239
|
+
*
|
|
240
|
+
* @param {number} itemIndex
|
|
241
|
+
*/
|
|
242
|
+
highlightItem(itemIndex, scrollIntoView = false) {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
const items = this.hostElement.shadowRoot.querySelectorAll('.list__item');
|
|
245
|
+
items.forEach(item => {
|
|
246
|
+
item.classList.remove(this.highlightedItemClassName);
|
|
247
|
+
});
|
|
248
|
+
(_a = items[itemIndex]) === null || _a === void 0 ? void 0 : _a.classList.add(this.highlightedItemClassName);
|
|
249
|
+
if (scrollIntoView) {
|
|
250
|
+
(_b = items[itemIndex]) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
251
|
+
}
|
|
245
252
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const items = Array.from(this.items);
|
|
270
|
-
items.forEach((item) => {
|
|
271
|
-
item.selected = false;
|
|
272
|
-
});
|
|
273
|
-
this.clearFilter();
|
|
253
|
+
/**
|
|
254
|
+
* Get sorted items.
|
|
255
|
+
* The sorting order is defined by the itemsOrder attribute.
|
|
256
|
+
*
|
|
257
|
+
* @param {HTMLMiDropdownItemElement[]} items
|
|
258
|
+
* @returns {HTMLMiDropdownItemElement[]}
|
|
259
|
+
*/
|
|
260
|
+
getSortedItems(items) {
|
|
261
|
+
if (this.itemsOrder === SortOrder.Asc) {
|
|
262
|
+
// Ascending order
|
|
263
|
+
items.sort((a, b) => (a.text || a.innerText)
|
|
264
|
+
.trimStart()
|
|
265
|
+
.toLowerCase()
|
|
266
|
+
.localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// Descending order
|
|
270
|
+
items.sort((b, a) => (a.text || a.innerText)
|
|
271
|
+
.trimStart()
|
|
272
|
+
.toLowerCase()
|
|
273
|
+
.localeCompare((b.text || b.innerText).trimStart().toLowerCase(), undefined, { numeric: true }));
|
|
274
|
+
}
|
|
275
|
+
return items;
|
|
274
276
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
* Highlights the item that the cursor is hovering in the content window.
|
|
282
|
-
*
|
|
283
|
-
* @param {number} filteredItemsIndex
|
|
284
|
-
*/
|
|
285
|
-
onMouseOver(filteredItemsIndex) {
|
|
286
|
-
if (!this.isMouseOverEventDisabled && !this.filterable) {
|
|
287
|
-
this.highlightItem(filteredItemsIndex);
|
|
288
|
-
this.currentItemIndex = filteredItemsIndex;
|
|
277
|
+
/**
|
|
278
|
+
* Update and emit list of selected items.
|
|
279
|
+
*/
|
|
280
|
+
onChangedHandler() {
|
|
281
|
+
this.selected = [...this.items.filter(item => item.selected)];
|
|
282
|
+
this.change.emit(this.selected);
|
|
289
283
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*/
|
|
296
|
-
filter() {
|
|
297
|
-
if (this.filterElement) {
|
|
298
|
-
const inputQuery = this.filterElement.value;
|
|
299
|
-
const miDropdownItemTexts = this.items.map(item => (item.text || item.innerText));
|
|
300
|
-
const numberOfItemsDisplayed = this.currentItems.length;
|
|
301
|
-
if (inputQuery === '') {
|
|
302
|
-
this.currentItemIndex = this.selectedItemIndex;
|
|
303
|
-
return this.currentItems = [...this.items];
|
|
304
|
-
}
|
|
305
|
-
const searchResultsOptions = {
|
|
306
|
-
limit: 50,
|
|
307
|
-
allowTypo: false,
|
|
308
|
-
threshold: -10000
|
|
309
|
-
};
|
|
310
|
-
const fuzzyResults = fuzzysort.go(inputQuery, miDropdownItemTexts, searchResultsOptions);
|
|
311
|
-
const filteredItems = fuzzyResults.map(result => this.items.find(item => (item.text || item.innerText) === result.target));
|
|
312
|
-
this.currentItems = filteredItems;
|
|
313
|
-
if (numberOfItemsDisplayed !== this.currentItems.length) {
|
|
314
|
-
this.currentItemIndex = 0;
|
|
315
|
-
}
|
|
284
|
+
/**
|
|
285
|
+
* Toggle visibility of content window.
|
|
286
|
+
*/
|
|
287
|
+
toggleContentWindow() {
|
|
288
|
+
this.open = !this.open;
|
|
316
289
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Select or toggle selection of item.
|
|
292
|
+
*
|
|
293
|
+
* @param {HTMLMiDropdownItemElement} item
|
|
294
|
+
*/
|
|
295
|
+
onSelect(item) {
|
|
296
|
+
if (!this.filterable) {
|
|
297
|
+
this.open = false;
|
|
298
|
+
const items = Array.from(this.items);
|
|
299
|
+
items.forEach((item) => {
|
|
300
|
+
item.selected = false;
|
|
301
|
+
});
|
|
302
|
+
this.clearFilter();
|
|
303
|
+
}
|
|
304
|
+
item.selected = !item.selected;
|
|
305
|
+
this.currentItemIndex = Number(item.dataset.index);
|
|
306
|
+
this.selectedItemIndex = this.currentItemIndex;
|
|
307
|
+
this.onChangedHandler();
|
|
327
308
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Helper function to render markup when no items are available to be displayed in the content window.
|
|
341
|
-
*
|
|
342
|
-
* @returns {JSX.Element}
|
|
343
|
-
*/
|
|
344
|
-
renderNoResultsTemplate() {
|
|
345
|
-
const noResultsTemplate = (h("div", { class: "empty-page" }, h("p", { class: "empty-page__header" }, this.noResultsMessage)));
|
|
346
|
-
return noResultsTemplate;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Helper function for rendering list item.
|
|
350
|
-
*
|
|
351
|
-
* @param {HTMLMiDropdownItemElement} item
|
|
352
|
-
* @param {number} index
|
|
353
|
-
* @param {boolean} showCheckBox
|
|
354
|
-
* @returns {JSX.Element}
|
|
355
|
-
*/
|
|
356
|
-
renderListItem(item, index, showCheckBox) {
|
|
357
|
-
let itemText;
|
|
358
|
-
const itemTooltipInfo = (item.getAttribute('title') || item.text || item.innerText);
|
|
359
|
-
if (item.innerText.length > 0) {
|
|
360
|
-
itemText = h("div", { class: "label__item label__item--from-inner-html", innerHTML: item.innerHTML });
|
|
309
|
+
/**
|
|
310
|
+
* Highlights the item that the cursor is hovering in the content window.
|
|
311
|
+
*
|
|
312
|
+
* @param {number} filteredItemsIndex
|
|
313
|
+
*/
|
|
314
|
+
onMouseOver(filteredItemsIndex) {
|
|
315
|
+
if (!this.isMouseOverEventDisabled && !this.filterable) {
|
|
316
|
+
this.highlightItem(filteredItemsIndex);
|
|
317
|
+
this.currentItemIndex = filteredItemsIndex;
|
|
318
|
+
}
|
|
361
319
|
}
|
|
362
|
-
|
|
363
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Filter items based on input query.
|
|
322
|
+
*
|
|
323
|
+
* @returns {HTMLMiDropdownItemElement[]}
|
|
324
|
+
*/
|
|
325
|
+
filter() {
|
|
326
|
+
if (this.filterElement) {
|
|
327
|
+
const inputQuery = this.filterElement.value;
|
|
328
|
+
const miDropdownItemTexts = this.items.map(item => (item.text || item.innerText));
|
|
329
|
+
const numberOfItemsDisplayed = this.currentItems.length;
|
|
330
|
+
if (inputQuery === '') {
|
|
331
|
+
this.currentItemIndex = this.selectedItemIndex;
|
|
332
|
+
return this.currentItems = [...this.items];
|
|
333
|
+
}
|
|
334
|
+
const searchResultsOptions = {
|
|
335
|
+
limit: 50,
|
|
336
|
+
allowTypo: false,
|
|
337
|
+
threshold: -1e4
|
|
338
|
+
};
|
|
339
|
+
const fuzzyResults = fuzzysort.go(inputQuery, miDropdownItemTexts, searchResultsOptions);
|
|
340
|
+
const filteredItems = fuzzyResults.map(result => this.items.find(item => (item.text || item.innerText) === result.target));
|
|
341
|
+
this.currentItems = filteredItems;
|
|
342
|
+
if (numberOfItemsDisplayed !== this.currentItems.length) {
|
|
343
|
+
this.currentItemIndex = 0;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
364
346
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
this.listElement.style.maxHeight = null;
|
|
376
|
-
this.listElement.style.minWidth = null;
|
|
377
|
-
const { clientWidth, clientHeight } = document.documentElement;
|
|
378
|
-
const hostElementRect = this.hostElement.getBoundingClientRect();
|
|
379
|
-
const listElementRect = this.listElement.getBoundingClientRect();
|
|
380
|
-
const availableSpaceBelowComponent = clientHeight - hostElementRect.bottom;
|
|
381
|
-
const availableSpaceAboveComponent = hostElementRect.top;
|
|
382
|
-
const MAX_HEIGHT = 580;
|
|
383
|
-
const MARGIN = 12;
|
|
384
|
-
if (clientWidth <= listElementRect.width || (hostElementRect.right - listElementRect.width < 0 && listElementRect.right > clientWidth)) {
|
|
385
|
-
this.listElement.style.right = `${MARGIN}px`;
|
|
386
|
-
this.listElement.style.left = `${MARGIN}px`;
|
|
387
|
-
this.listElement.style.minWidth = 'unset';
|
|
347
|
+
/**
|
|
348
|
+
* Clear filter.
|
|
349
|
+
*/
|
|
350
|
+
clearFilter() {
|
|
351
|
+
var _a;
|
|
352
|
+
if (this.filterElement) {
|
|
353
|
+
this.filterElement.value = (_a = this.selected[0]) === null || _a === void 0 ? void 0 : _a.text;
|
|
354
|
+
this.filterElement.blur();
|
|
355
|
+
this.currentItems = this.items;
|
|
356
|
+
}
|
|
388
357
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Render input field - combobox.
|
|
360
|
+
*
|
|
361
|
+
* @returns {Host}
|
|
362
|
+
*/
|
|
363
|
+
render() {
|
|
364
|
+
var _a;
|
|
365
|
+
const listOfItems = (h("ul", { key: 'f6b41bb0354bf67724906748853706dc88d82d44', class: "list" }, this.currentItems.map((item, index) => this.renderListItem(item, index, this.filterable))));
|
|
366
|
+
return (h(Host, { key: '67bdf9b1ef80cd02e9c5e5c222cc57b4403d944f', class: { 'open': this.open } }, h("input", { key: '7696e84b9761fffdea045bc058b461bdde2558a6', type: "text", class: "input", onFocus: (event) => this.onClickExists(event), ref: (el) => this.filterElement = el, onInput: () => this.filter(), tabIndex: 0, value: (_a = this.selected[0]) === null || _a === void 0 ? void 0 : _a.text }), h("svg", { key: '520bb60108aa631de484f64d24e84f471e14387a', role: 'button', class: "input__svg", part: "icon-down-arrow", width: "12", height: "6", viewBox: "0 0 18 10", xmlns: "http://www.w3.org/2000/svg", onClick: () => this.toggleContentWindow() }, h("path", { key: '70aae628fde18fac4bddf606b72111384ab66196', 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: '3d79acbb1daaa7a03f3af83106d2c186bdeda585', ref: (el) => this.listElement = el, part: "dropdown-container", class: "content" }, this.currentItems.length === 0 ? this.renderNoResultsTemplate() : listOfItems)));
|
|
392
367
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Helper function to render markup when no items are available to be displayed in the content window.
|
|
370
|
+
*
|
|
371
|
+
* @returns {JSX.Element}
|
|
372
|
+
*/
|
|
373
|
+
renderNoResultsTemplate() {
|
|
374
|
+
const noResultsTemplate = (h("div", { class: "empty-page" }, h("p", { class: "empty-page__header" }, this.noResultsMessage)));
|
|
375
|
+
return noResultsTemplate;
|
|
396
376
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Helper function for rendering list item.
|
|
379
|
+
*
|
|
380
|
+
* @param {HTMLMiDropdownItemElement} item
|
|
381
|
+
* @param {number} index
|
|
382
|
+
* @param {boolean} showCheckBox
|
|
383
|
+
* @returns {JSX.Element}
|
|
384
|
+
*/
|
|
385
|
+
renderListItem(item, index, showCheckBox) {
|
|
386
|
+
let itemText;
|
|
387
|
+
const itemTooltipInfo = (item.getAttribute('title') || item.text || item.innerText);
|
|
388
|
+
if (item.innerText.length > 0) {
|
|
389
|
+
itemText = h("div", { class: "label__item label__item--from-inner-html", innerHTML: item.innerHTML });
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
itemText = h("div", { class: "label__item", innerHTML: item.text });
|
|
393
|
+
}
|
|
394
|
+
return (h("li", { class: "list__item", 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, onChange: () => this.onSelect(item) }), itemText)));
|
|
401
395
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Function for calculating the position of the dropdown list element.
|
|
398
|
+
*/
|
|
399
|
+
calculateDropDownPosition() {
|
|
400
|
+
this.listElement.style.bottom = null;
|
|
401
|
+
this.listElement.style.left = null;
|
|
402
|
+
this.listElement.style.right = null;
|
|
403
|
+
this.listElement.style.top = null;
|
|
404
|
+
this.listElement.style.maxHeight = null;
|
|
405
|
+
this.listElement.style.minWidth = null;
|
|
406
|
+
const { clientWidth, clientHeight } = document.documentElement;
|
|
407
|
+
const hostElementRect = this.hostElement.getBoundingClientRect();
|
|
408
|
+
const listElementRect = this.listElement.getBoundingClientRect();
|
|
409
|
+
const availableSpaceBelowComponent = clientHeight - hostElementRect.bottom;
|
|
410
|
+
const availableSpaceAboveComponent = hostElementRect.top;
|
|
411
|
+
const MAX_HEIGHT = 580;
|
|
412
|
+
const MARGIN = 12;
|
|
413
|
+
if (clientWidth <= listElementRect.width || (hostElementRect.right - listElementRect.width < 0 && listElementRect.right > clientWidth)) {
|
|
414
|
+
this.listElement.style.right = `${MARGIN}px`;
|
|
415
|
+
this.listElement.style.left = `${MARGIN}px`;
|
|
416
|
+
this.listElement.style.minWidth = 'unset';
|
|
417
|
+
}
|
|
418
|
+
else if (listElementRect.right > clientWidth) {
|
|
419
|
+
this.listElement.style.left = 'unset';
|
|
420
|
+
this.listElement.style.right = `${clientWidth - hostElementRect.right}px`;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
this.listElement.style.left = `${hostElementRect.left}px`;
|
|
424
|
+
this.listElement.style.right = 'unset';
|
|
425
|
+
}
|
|
426
|
+
if (availableSpaceAboveComponent > availableSpaceBelowComponent) {
|
|
427
|
+
this.listElement.style.maxHeight = `${Math.min(availableSpaceAboveComponent, MAX_HEIGHT)}px`;
|
|
428
|
+
this.listElement.style.top = 'unset';
|
|
429
|
+
this.listElement.style.bottom = `${clientHeight - hostElementRect.top}px`;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this.listElement.style.top = `${hostElementRect.bottom}px`;
|
|
433
|
+
this.listElement.style.bottom = 'unset';
|
|
434
|
+
this.listElement.style.maxHeight = `${Math.min(availableSpaceBelowComponent - (MARGIN * 2), MAX_HEIGHT)}px`;
|
|
435
|
+
}
|
|
406
436
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
437
|
+
get hostElement() { return getElement(this); }
|
|
438
|
+
static get watchers() { return {
|
|
439
|
+
"items": [{
|
|
440
|
+
"onItemsChanged": 0
|
|
441
|
+
}],
|
|
442
|
+
"currentItems": [{
|
|
443
|
+
"onCurrentItemsChange": 0
|
|
444
|
+
}]
|
|
445
|
+
}; }
|
|
413
446
|
};
|
|
414
|
-
ComboBox.style = comboBoxCss;
|
|
447
|
+
ComboBox.style = comboBoxCss();
|
|
415
448
|
|
|
416
449
|
export { ComboBox as mi_combo_box };
|