@mapsindoors/map-template 1.0.0-rc.1
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/README.md +123 -0
- package/dist/_commonjsHelpers-ba3f0406-b96e6d6a.mjs +21 -0
- package/dist/combo-box-item.entry-92232c29.mjs +12 -0
- package/dist/combo-box-item.entry-f244c01a.mjs +14 -0
- package/dist/icon-b8d01d6f-ddfa2c17.mjs +24 -0
- package/dist/mapsindoors-react.es.js +7 -0
- package/dist/mapsindoors-react.umd.js +1391 -0
- package/dist/mapsindoors-webcomponent.es.js +5 -0
- package/dist/mapsindoors-webcomponent.umd.js +1385 -0
- package/dist/mi-card_2.entry-508f65b2.mjs +23 -0
- package/dist/mi-card_2.entry-d24478d0.mjs +25 -0
- package/dist/mi-chip.entry-74b3118c.mjs +15 -0
- package/dist/mi-chip.entry-8bfee95c.mjs +13 -0
- package/dist/mi-column.entry-f66623b9.mjs +20 -0
- package/dist/mi-column.entry-f901d5d1.mjs +18 -0
- package/dist/mi-combo-box.entry-0e6d9797.mjs +262 -0
- package/dist/mi-combo-box.entry-69a04955.mjs +260 -0
- package/dist/mi-data-table.entry-6cae08b0.mjs +215 -0
- package/dist/mi-data-table.entry-7fe09cbe.mjs +213 -0
- package/dist/mi-distance_2.entry-dca308c3.mjs +54 -0
- package/dist/mi-distance_2.entry-dffb2e64.mjs +56 -0
- package/dist/mi-dropdown-item.entry-508c6605.mjs +12 -0
- package/dist/mi-dropdown-item.entry-b6aa9d36.mjs +14 -0
- package/dist/mi-dropdown.entry-43258637.mjs +296 -0
- package/dist/mi-dropdown.entry-e1325610.mjs +298 -0
- package/dist/mi-keyboard.entry-60e47fb9.mjs +2962 -0
- package/dist/mi-keyboard.entry-c97c80e8.mjs +2960 -0
- package/dist/mi-list-item-category.entry-b0f61751.mjs +38 -0
- package/dist/mi-list-item-category.entry-bcac342a.mjs +36 -0
- package/dist/mi-list-item-location.entry-15ec9c7e.mjs +125 -0
- package/dist/mi-list-item-location.entry-ee56967a.mjs +127 -0
- package/dist/mi-list.entry-656130ea.mjs +41 -0
- package/dist/mi-list.entry-c8f1f377.mjs +39 -0
- package/dist/mi-location-booking.entry-a5b9b331.mjs +4863 -0
- package/dist/mi-location-booking.entry-ea841d6e.mjs +4865 -0
- package/dist/mi-location-info.entry-89b37774.mjs +22 -0
- package/dist/mi-location-info.entry-fe2c6c32.mjs +24 -0
- package/dist/mi-map-googlemaps.entry-6cb264de.mjs +398 -0
- package/dist/mi-map-googlemaps.entry-8877f16d.mjs +396 -0
- package/dist/mi-map-mapbox.entry-7a41963d.mjs +298 -0
- package/dist/mi-map-mapbox.entry-928da21a.mjs +300 -0
- package/dist/mi-metric-card.entry-51daca25.mjs +28 -0
- package/dist/mi-metric-card.entry-95dbb9f1.mjs +26 -0
- package/dist/mi-notification.entry-29b28ba8.mjs +81 -0
- package/dist/mi-notification.entry-f7677761.mjs +83 -0
- package/dist/mi-route-instructions-heading.entry-79c22cdd.mjs +72 -0
- package/dist/mi-route-instructions-heading.entry-a4c7f18f.mjs +74 -0
- package/dist/mi-route-instructions-maneuver_2.entry-383704ad.mjs +115 -0
- package/dist/mi-route-instructions-maneuver_2.entry-80c51e6a.mjs +113 -0
- package/dist/mi-route-instructions-step-legacy.entry-785cb60b.mjs +199 -0
- package/dist/mi-route-instructions-step-legacy.entry-eff068ed.mjs +201 -0
- package/dist/mi-route-instructions-step.entry-272e3c84.mjs +199 -0
- package/dist/mi-route-instructions-step.entry-95f5dc43.mjs +201 -0
- package/dist/mi-route-instructions.entry-0628d220.mjs +139 -0
- package/dist/mi-route-instructions.entry-1b4fb352.mjs +141 -0
- package/dist/mi-scroll-buttons.entry-274b003f.mjs +48 -0
- package/dist/mi-scroll-buttons.entry-6132935b.mjs +46 -0
- package/dist/mi-search.entry-994c0189.mjs +206 -0
- package/dist/mi-search.entry-d0e582d1.mjs +208 -0
- package/dist/mi-share-sms.entry-ae15cf77.mjs +53 -0
- package/dist/mi-share-sms.entry-ced7f275.mjs +55 -0
- package/dist/mi-step-switcher.entry-812a5096.mjs +24 -0
- package/dist/mi-step-switcher.entry-c9e28e79.mjs +26 -0
- package/dist/mi-tab-panel.entry-63c34f28.mjs +19 -0
- package/dist/mi-tab-panel.entry-bde9bd39.mjs +21 -0
- package/dist/mi-tab.entry-1767468e.mjs +13 -0
- package/dist/mi-tab.entry-b5ac50ac.mjs +11 -0
- package/dist/mi-tabs.entry-1b8327bf.mjs +34 -0
- package/dist/mi-tabs.entry-bd190e21.mjs +36 -0
- package/dist/mi-variables-9a6c8d4d-e06eec88.mjs +7 -0
- package/dist/reactcomponent-2f9f051f.mjs +27190 -0
- package/dist/route-travel-mode.enum-7f4ce9c7-a9c95a83.mjs +7 -0
- package/dist/sort-order.enum-64ce8998-b75ac596.mjs +317 -0
- package/dist/unit-system.enum-eaefb53e-0f424da4.mjs +7 -0
- package/dist/utils-ae714467-b07fc3be.mjs +36 -0
- package/dist/webcomponent-a10be1e6.mjs +31969 -0
- package/package.json +53 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { r as c, c as d, h as n, H as p, g as u } from "./webcomponent-a10be1e6.mjs";
|
|
2
|
+
import { S as m, f as g } from "./sort-order.enum-64ce8998-b75ac596.mjs";
|
|
3
|
+
import "./_commonjsHelpers-ba3f0406-b96e6d6a.mjs";
|
|
4
|
+
const f = `.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}`;
|
|
5
|
+
var l;
|
|
6
|
+
(function(e) {
|
|
7
|
+
e.ArrowDown = "ArrowDown", e.ArrowUp = "ArrowUp", e.Enter = "Enter", e.Esc = "Escape";
|
|
8
|
+
})(l || (l = {}));
|
|
9
|
+
const x = class {
|
|
10
|
+
constructor(e) {
|
|
11
|
+
c(this, e), this.change = d(this, "change", 3), this.isFilterSelectionDisabled = !1, this.isMouseOverEventDisabled = !1, this.currentItemIndex = 0, this.selectedItemIndex = 0, this.highlightedItemClassName = "list__item--highlighted", this.open = !1, this.items = [], this.itemsOrder = void 0, this.filterable = !1, this.selected = [], this.noResultsMessage = "No results found", this.currentItems = [], this.disabled = !1;
|
|
12
|
+
}
|
|
13
|
+
onItemsChanged(e) {
|
|
14
|
+
if (e.some((t) => t.tagName.toLowerCase() !== "combo-box-item"))
|
|
15
|
+
throw new Error("Items contains unknown element(s).");
|
|
16
|
+
if (Object.values(m).includes(this.itemsOrder) && (e = this.getSortedItems(e)), this.currentItems = [...e], this.filter(), !this.filterable) {
|
|
17
|
+
const t = this.currentItems.findIndex((i) => i.selected);
|
|
18
|
+
this.currentItemIndex = t > -1 ? t : 0, this.selectedItemIndex = this.currentItemIndex;
|
|
19
|
+
}
|
|
20
|
+
this.items.forEach((t, i) => {
|
|
21
|
+
t.dataset.index = i.toString();
|
|
22
|
+
}), this.selectFirstMiDropdownItem();
|
|
23
|
+
}
|
|
24
|
+
onCurrentItemsChange() {
|
|
25
|
+
this.isFilterSelectionDisabled = this.currentItems.length === 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Outside the dropdown listener. It will close the dropdown when a click is outside a dropdown and dropdown list.
|
|
29
|
+
*
|
|
30
|
+
* @param {ev} ev
|
|
31
|
+
*/
|
|
32
|
+
checkForClickOutside(e) {
|
|
33
|
+
var t;
|
|
34
|
+
!this.hostElement.contains(e.target) && this.noResultsMessage && (this.clearFilter(), this.filterElement.value = (t = this.selected[0]) === null || t === void 0 ? void 0 : t.text, this.open = !1);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* When clicked on input button we change it's type to text and highlight value that is inside.
|
|
38
|
+
*
|
|
39
|
+
* @param {Event} event
|
|
40
|
+
*/
|
|
41
|
+
onClickExists(e) {
|
|
42
|
+
this.open = !0, e.target.type = "text", this.filterElement.select();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mousemove event handler.
|
|
46
|
+
* When the mouse is moved the mouseover event handler is enabled.
|
|
47
|
+
*/
|
|
48
|
+
mouseMoveEventHandler() {
|
|
49
|
+
this.isMouseOverEventDisabled = !1;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Scroll event handler.
|
|
53
|
+
* The dropdown is closed when the scroll event is trigget outside the dropdown.
|
|
54
|
+
*/
|
|
55
|
+
scrollEventHandler(e) {
|
|
56
|
+
const t = e.target;
|
|
57
|
+
(!t || !this.hostElement.contains(t)) && (this.open = !1);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resize event handler.
|
|
61
|
+
* Recalculate the position of the dropdown when the window is resized.
|
|
62
|
+
*/
|
|
63
|
+
resizeEventHandler() {
|
|
64
|
+
this.calculateDropDownPosition();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Component did load.
|
|
68
|
+
*/
|
|
69
|
+
componentDidLoad() {
|
|
70
|
+
this.createMiDropdownItemsFromDocument(), this.selectFirstMiDropdownItem(), this.enableKeyboardNavigationEvents();
|
|
71
|
+
const e = new IntersectionObserver((t) => {
|
|
72
|
+
t.forEach((i) => {
|
|
73
|
+
i.isIntersecting === !0 && this.filterElement.blur();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
this.filterElement !== void 0 && (e.observe(this.filterElement), this.filterElement.addEventListener("keydown", (t) => {
|
|
77
|
+
(t.key === l.ArrowDown || t.key === l.ArrowUp) && t.preventDefault();
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Component did rener.
|
|
82
|
+
*/
|
|
83
|
+
componentDidRender() {
|
|
84
|
+
this.calculateDropDownPosition(), this.filterable || this.highlightItem(this.currentItemIndex, !0);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets all mi-dropdown-item elements for the mi-dropdown items property.
|
|
88
|
+
*/
|
|
89
|
+
createMiDropdownItemsFromDocument() {
|
|
90
|
+
const e = this.items && this.items.length > 0 ? this.items : this.hostElement.querySelectorAll("combo-box-item");
|
|
91
|
+
e.length > 0 && (this.items = Array.from(e));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set the first mi-dropdown-item as the textual content of the button.
|
|
95
|
+
*/
|
|
96
|
+
selectFirstMiDropdownItem() {
|
|
97
|
+
var e;
|
|
98
|
+
if (!this.filterable) {
|
|
99
|
+
const t = (e = this.items) === null || e === void 0 ? void 0 : e.findIndex((i) => i.selected);
|
|
100
|
+
this.selected = [this.items[t > -1 ? t : 0]];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Enables cycling through the items in the content window using arrow up/down keys.
|
|
105
|
+
*/
|
|
106
|
+
enableKeyboardNavigationEvents() {
|
|
107
|
+
this.hostElement.addEventListener("keydown", (e) => {
|
|
108
|
+
if (this.open === !1 && e.key === l.ArrowDown) {
|
|
109
|
+
this.isMouseOverEventDisabled = !0, this.toggleContentWindow(), e.preventDefault();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.open === !0 && !this.filterable)
|
|
113
|
+
switch (e.key) {
|
|
114
|
+
case (l.ArrowDown || l.ArrowUp):
|
|
115
|
+
this.isMouseOverEventDisabled = !0, this.currentItemIndex = (this.currentItemIndex + 1) % this.currentItems.length, this.highlightItem(this.currentItemIndex, !0), e.preventDefault();
|
|
116
|
+
break;
|
|
117
|
+
case l.ArrowUp:
|
|
118
|
+
this.isMouseOverEventDisabled = !0, this.currentItemIndex = (this.currentItemIndex + this.currentItems.length - 1) % this.currentItems.length, this.highlightItem(this.currentItemIndex, !0), e.preventDefault();
|
|
119
|
+
break;
|
|
120
|
+
case l.Enter:
|
|
121
|
+
if (this.hostElement.shadowRoot.activeElement === this.clearButtonElement)
|
|
122
|
+
return;
|
|
123
|
+
this.currentItems[this.currentItemIndex] !== void 0 && this.onSelect(this.currentItems[this.currentItemIndex]), e.preventDefault();
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
e.key === l.Esc && (this.filterable || (this.currentItemIndex = this.selectedItemIndex, this.highlightItem(this.currentItemIndex)), this.toggleContentWindow(), this.clearFilter());
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Updates the currently highlighted item in the markup.
|
|
131
|
+
*
|
|
132
|
+
* @param {number} itemIndex
|
|
133
|
+
*/
|
|
134
|
+
highlightItem(e, t = !1) {
|
|
135
|
+
var i, s;
|
|
136
|
+
const r = this.hostElement.shadowRoot.querySelectorAll(".list__item");
|
|
137
|
+
r.forEach((a) => {
|
|
138
|
+
a.classList.remove(this.highlightedItemClassName);
|
|
139
|
+
}), (i = r[e]) === null || i === void 0 || i.classList.add(this.highlightedItemClassName), t && ((s = r[e]) === null || s === void 0 || s.scrollIntoView({ block: "nearest", inline: "nearest" }));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get sorted items.
|
|
143
|
+
* The sorting order is defined by the itemsOrder attribute.
|
|
144
|
+
*
|
|
145
|
+
* @param {HTMLMiDropdownItemElement[]} items
|
|
146
|
+
* @returns {HTMLMiDropdownItemElement[]}
|
|
147
|
+
*/
|
|
148
|
+
getSortedItems(e) {
|
|
149
|
+
return this.itemsOrder === m.Asc ? e.sort((t, i) => (t.text || t.innerText).trimStart().toLowerCase().localeCompare((i.text || i.innerText).trimStart().toLowerCase(), void 0, { numeric: !0 })) : e.sort((t, i) => (i.text || i.innerText).trimStart().toLowerCase().localeCompare((t.text || t.innerText).trimStart().toLowerCase(), void 0, { numeric: !0 })), e;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Update and emit list of selected items.
|
|
153
|
+
*/
|
|
154
|
+
onChangedHandler() {
|
|
155
|
+
this.selected = [...this.items.filter((e) => e.selected)], this.change.emit(this.selected);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Toggle visibility of content window.
|
|
159
|
+
*/
|
|
160
|
+
toggleContentWindow() {
|
|
161
|
+
this.open = !this.open;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Select or toggle selection of item.
|
|
165
|
+
*
|
|
166
|
+
* @param {HTMLMiDropdownItemElement} item
|
|
167
|
+
*/
|
|
168
|
+
onSelect(e) {
|
|
169
|
+
this.filterable || (this.open = !1, Array.from(this.items).forEach((i) => {
|
|
170
|
+
i.selected = !1;
|
|
171
|
+
}), this.clearFilter()), e.selected = !e.selected, this.currentItemIndex = Number(e.dataset.index), this.selectedItemIndex = this.currentItemIndex, this.onChangedHandler();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Highlights the item that the cursor is hovering in the content window.
|
|
175
|
+
*
|
|
176
|
+
* @param {number} filteredItemsIndex
|
|
177
|
+
*/
|
|
178
|
+
onMouseOver(e) {
|
|
179
|
+
!this.isMouseOverEventDisabled && !this.filterable && (this.highlightItem(e), this.currentItemIndex = e);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Filter items based on input query.
|
|
183
|
+
*
|
|
184
|
+
* @returns {HTMLMiDropdownItemElement[]}
|
|
185
|
+
*/
|
|
186
|
+
filter() {
|
|
187
|
+
if (this.filterElement) {
|
|
188
|
+
const e = this.filterElement.value, t = this.items.map((o) => o.text || o.innerText), i = this.currentItems.length;
|
|
189
|
+
if (e === "")
|
|
190
|
+
return this.currentItemIndex = this.selectedItemIndex, this.currentItems = [...this.items];
|
|
191
|
+
const s = {
|
|
192
|
+
limit: 50,
|
|
193
|
+
allowTypo: !1,
|
|
194
|
+
threshold: -1e4
|
|
195
|
+
}, a = g.go(e, t, s).map((o) => this.items.find((h) => (h.text || h.innerText) === o.target));
|
|
196
|
+
this.currentItems = a, i !== this.currentItems.length && (this.currentItemIndex = 0);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Clear filter.
|
|
201
|
+
*/
|
|
202
|
+
clearFilter() {
|
|
203
|
+
var e;
|
|
204
|
+
this.filterElement && (this.filterElement.value = (e = this.selected[0]) === null || e === void 0 ? void 0 : e.text, this.filterElement.blur(), this.currentItems = this.items);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Render input field - combobox.
|
|
208
|
+
*
|
|
209
|
+
* @returns {Host}
|
|
210
|
+
*/
|
|
211
|
+
render() {
|
|
212
|
+
var e;
|
|
213
|
+
const t = n("ul", { class: "list" }, this.currentItems.map((i, s) => this.renderListItem(i, s, this.filterable)));
|
|
214
|
+
return n(p, { class: { open: this.open } }, n("input", { type: "text", class: "input", onFocus: (i) => this.onClickExists(i), ref: (i) => this.filterElement = i, onInput: () => this.filter(), tabIndex: 0, value: (e = this.selected[0]) === null || e === void 0 ? void 0 : e.text }), n("svg", { 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() }, n("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" })), n("section", { ref: (i) => this.listElement = i, part: "dropdown-container", class: "content" }, this.currentItems.length === 0 ? this.renderNoResultsTemplate() : t));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Helper function to render markup when no items are available to be displayed in the content window.
|
|
218
|
+
*
|
|
219
|
+
* @returns {JSX.Element}
|
|
220
|
+
*/
|
|
221
|
+
renderNoResultsTemplate() {
|
|
222
|
+
return n("div", { class: "empty-page" }, n("p", { class: "empty-page__header" }, this.noResultsMessage));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Helper function for rendering list item.
|
|
226
|
+
*
|
|
227
|
+
* @param {HTMLMiDropdownItemElement} item
|
|
228
|
+
* @param {number} index
|
|
229
|
+
* @param {boolean} showCheckBox
|
|
230
|
+
* @returns {JSX.Element}
|
|
231
|
+
*/
|
|
232
|
+
renderListItem(e, t, i) {
|
|
233
|
+
let s;
|
|
234
|
+
const r = e.getAttribute("title") || e.text || e.innerText;
|
|
235
|
+
return e.innerText.length > 0 ? s = n("div", { class: "label__item label__item--from-inner-html", innerHTML: e.innerHTML }) : s = n("div", { class: "label__item", innerHTML: e.text }), n("li", { class: "list__item", title: r, onMouseOver: () => {
|
|
236
|
+
this.onMouseOver(t);
|
|
237
|
+
} }, n("label", { class: "mi-label label", tabindex: "-1" }, n("input", { class: { label__checkbox: !0, "label__checkbox--hidden": !i, "mi-input": !0 }, type: "checkbox", value: t, checked: e.selected, onChange: () => this.onSelect(e) }), s));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Function for calculating the position of the dropdown list element.
|
|
241
|
+
*/
|
|
242
|
+
calculateDropDownPosition() {
|
|
243
|
+
this.listElement.style.bottom = null, this.listElement.style.left = null, this.listElement.style.right = null, this.listElement.style.top = null, this.listElement.style.maxHeight = null, this.listElement.style.minWidth = null;
|
|
244
|
+
const { clientWidth: e, clientHeight: t } = document.documentElement, i = this.hostElement.getBoundingClientRect(), s = this.listElement.getBoundingClientRect(), r = t - i.bottom, a = i.top, o = 580, h = 12;
|
|
245
|
+
e <= s.width || i.right - s.width < 0 && s.right > e ? (this.listElement.style.right = `${h}px`, this.listElement.style.left = `${h}px`, this.listElement.style.minWidth = "unset") : s.right > e ? (this.listElement.style.left = "unset", this.listElement.style.right = `${e - i.right}px`) : (this.listElement.style.left = `${i.left}px`, this.listElement.style.right = "unset"), a > r ? (this.listElement.style.maxHeight = `${Math.min(a, o)}px`, this.listElement.style.top = "unset", this.listElement.style.bottom = `${t - i.top}px`) : (this.listElement.style.top = `${i.bottom}px`, this.listElement.style.bottom = "unset", this.listElement.style.maxHeight = `${Math.min(r - h * 2, o)}px`);
|
|
246
|
+
}
|
|
247
|
+
get hostElement() {
|
|
248
|
+
return u(this);
|
|
249
|
+
}
|
|
250
|
+
static get watchers() {
|
|
251
|
+
return {
|
|
252
|
+
items: ["onItemsChanged"],
|
|
253
|
+
currentItems: ["onCurrentItemsChange"]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
x.style = f;
|
|
258
|
+
export {
|
|
259
|
+
x as mi_combo_box
|
|
260
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { r as s, c as h, h as o, H as c, g } from "./reactcomponent-2f9f051f.mjs";
|
|
2
|
+
import { i as l, a as b } from "./utils-ae714467-b07fc3be.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
const p = `a.mi-button{cursor:default}.mi-button{border-radius:4px;border-width:1px;border-style:solid;font-family:Inter, -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";font-size:1rem;font-weight:500;padding-left:16px;padding-right:16px;padding-top:12px;padding-bottom:12px;display:inline-flex;align-items:center}.mi-button:disabled{opacity:0.48;cursor:not-allowed}.mi-button object{filter:invert(9%) sepia(13%) saturate(692%) hue-rotate(185deg) brightness(98%) contrast(91%);width:16px;height:16px}.mi-button--small{padding-left:12px;padding-right:12px;padding-top:8px;padding-bottom:8px;font-size:0.875rem;height:32px}.mi-button--small object{width:16px;height:16px}.mi-button--large{padding-left:16px;padding-right:16px;font-size:1.25rem}.mi-button--large object{width:20px;height:20px}.mi-button--full-width{width:100%;justify-content:center}.mi-button--icon-left{padding-left:12px}.mi-button--icon-left object{margin-right:8px}.mi-button--icon-right{padding-right:12px}.mi-button--icon-right object{margin-left:8px}.mi-button--icon-both{padding-top:12px;padding-bottom:12px}.mi-button--icon-both object:first-of-type{margin-right:8px}.mi-button--icon-both object:last-of-type{margin-left:8px}.mi-button--base{background:linear-gradient(#f5f7fa, #ebeff5);color:#1e2025;border-color:#c8d0e0}.mi-button--base:not(:disabled):hover{background:linear-gradient(#ebeff5, #dee3ed);border-color:#aeb9cb}.mi-button--base:not(:disabled):active{background:linear-gradient(#dee3ed, #ebeff5)}.mi-button--primary{color:#ffffff;border-color:#20693e;background:linear-gradient(#3ba064, #2a844e)}.mi-button--primary object{filter:invert(100%) sepia(93%) saturate(0%) hue-rotate(201deg) brightness(106%) contrast(106%)}.mi-button--primary:not(:disabled):hover{background:linear-gradient(#2a844e, #20693e)}.mi-button--primary:not(:disabled):active{background:linear-gradient(#20693e, #2a844e)}.mi-button--delete{background:linear-gradient(#f55151, #de1b1b);color:#ffffff;border-color:#ba0d0d}.mi-button--delete object{filter:invert(100%) sepia(93%) saturate(0%) hue-rotate(201deg) brightness(106%) contrast(106%)}.mi-button--delete:not(:disabled):hover{background:linear-gradient(#de1b1b, #ba0d0d)}.mi-button--delete:not(:disabled):active{background:linear-gradient(#ba0d0d, #de1b1b)}.mi-button--outline{color:#3071d9;border-color:#3071d9;background-color:transparent}.mi-button--outline object{filter:invert(38%) sepia(97%) saturate(742%) hue-rotate(188deg) brightness(86%) contrast(97%)}.mi-button--outline:not(:disabled):hover{color:#1d5bbf;border-color:#1d5bbf;background-color:#eef4fc}.mi-button--outline:not(:disabled):active{color:#1d5bbf;border-color:#1d5bbf;background-color:#cfe0fc}.mi-button--link{color:#3071d9;border-style:none;background-color:transparent;cursor:pointer}.mi-button--link object{filter:invert(38%) sepia(97%) saturate(742%) hue-rotate(188deg) brightness(86%) contrast(97%)}.mi-button--link:not(:disabled):hover{color:#1d5bbf;border-color:#1d5bbf;background-color:#eef4fc}.mi-button--link:disabled:hover{cursor:not-allowed}.mi-button--link:not(:disabled):active{color:#1d5bbf;border-color:#1d5bbf;background-color:#cfe0fc}.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-select{display:block;padding-top:8px;padding-bottom:8px;padding-left:8px;padding-right:32px;border-radius:4px;border-width:1px;border-style:solid;border-color:#c8d0e0;color:#1e2025;font-size:1rem;font-weight:500;-webkit-appearance:none;-moz-appearance:none;appearance:none;background:url("data:image/svg+xml;base64,PHN2ZyBmaWxsPScjNDQ0QjU1JyBoZWlnaHQ9JzI0JyB2aWV3Qm94PScwIDAgMjQgMjQnIHdpZHRoPScyNCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz4KPHBhdGggZD0nTTcgMTBsNSA1IDUtNXonLz4KPHBhdGggZD0nTTAgMGgyNHYyNEgweicgZmlsbD0nbm9uZScvPgo8L3N2Zz4=") 96%/24px no-repeat, linear-gradient(#f5f7fa, #ebeff5)}.mi-select:disabled{opacity:0.48;cursor:not-allowed}.mi-select:not(:disabled):hover{background:url("data:image/svg+xml;base64,PHN2ZyBmaWxsPScjNDQ0QjU1JyBoZWlnaHQ9JzI0JyB2aWV3Qm94PScwIDAgMjQgMjQnIHdpZHRoPScyNCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz4KPHBhdGggZD0nTTcgMTBsNSA1IDUtNXonLz4KPHBhdGggZD0nTTAgMGgyNHYyNEgweicgZmlsbD0nbm9uZScvPgo8L3N2Zz4=") 96%/24px no-repeat, linear-gradient(#ebeff5, #dee3ed);border-color:#aeb9cb}.mi-select:not(:disabled):active{background:url("data:image/svg+xml;base64,PHN2ZyBmaWxsPScjNDQ0QjU1JyBoZWlnaHQ9JzI0JyB2aWV3Qm94PScwIDAgMjQgMjQnIHdpZHRoPScyNCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz4KPHBhdGggZD0nTTcgMTBsNSA1IDUtNXonLz4KPHBhdGggZD0nTTAgMGgyNHYyNEgweicgZmlsbD0nbm9uZScvPgo8L3N2Zz4=") 96%/24px no-repeat, linear-gradient(#dee3ed, #ebeff5)}.mi-toggle{margin:0}.mi-toggle:disabled{cursor:not-allowed}.mi-toggle+.mi-label{margin-left:8px}@supports (appearance: none) or (-moz-appearance: none) or (-webkit-appearance: none){.mi-toggle{padding:2px;box-sizing:border-box;appearance:none;-moz-appearance:none;-webkit-appearance:none;width:48px;height:24px;border-radius:9999px;background-color:#8d98aa;transition:background-color 300ms ease}.mi-toggle:disabled{opacity:0.48}.mi-toggle:checked{background-color:#2a844e}.mi-toggle::after{content:"";display:inline-block;width:20px;height:20px;transform:translateX(0px);border-radius:50%;background-color:#fcfcfc;box-shadow:0 1px 1px rgba(0, 0, 0, 0.125), 0 2px 2px rgba(0, 0, 0, 0.125);transition:300ms ease}.mi-toggle:checked::after{transform:translateX(24px)}}.width-none{width:0}.width-xxx-small{width:2px}.width-xx-small{width:4px}.width-x-small{width:8px}.width-small{width:12px}.width-medium{width:16px}.width-large{width:24px}.width-x-large{width:32px}.width-xx-large{width:40px}.width-xxx-large{width:48px}.width-xxxx-large{width:64px}.min-width-none{min-width:0}.min-width-xxx-small{min-width:2px}.min-width-xx-small{min-width:4px}.min-width-x-small{min-width:8px}.min-width-small{min-width:12px}.min-width-medium{min-width:16px}.min-width-large{min-width:24px}.min-width-x-large{min-width:32px}.min-width-xx-large{min-width:40px}.min-width-xxx-large{min-width:48px}.min-width-xxxx-large{min-width:64px}.max-width-none{max-width:0}.max-width-xxx-small{max-width:2px}.max-width-xx-small{max-width:4px}.max-width-x-small{max-width:8px}.max-width-small{max-width:12px}.max-width-medium{max-width:16px}.max-width-large{max-width:24px}.max-width-x-large{max-width:32px}.max-width-xx-large{max-width:40px}.max-width-xxx-large{max-width:48px}.max-width-xxxx-large{max-width:64px}.height-none{height:0}.height-xxx-small{height:2px}.height-xx-small{height:4px}.height-x-small{height:8px}.height-small{height:12px}.height-medium{height:16px}.height-large{height:24px}.height-x-large{height:32px}.height-xx-large{height:40px}.height-xxx-large{height:48px}.height-xxxx-large{height:64px}.min-height-none{min-height:0}.min-height-xxx-small{min-height:2px}.min-height-xx-small{min-height:4px}.min-height-x-small{min-height:8px}.min-height-small{min-height:12px}.min-height-medium{min-height:16px}.min-height-large{min-height:24px}.min-height-x-large{min-height:32px}.min-height-xx-large{min-height:40px}.min-height-xxx-large{min-height:48px}.min-height-xxxx-large{min-height:64px}.max-height-none{max-height:0}.max-height-xxx-small{max-height:2px}.max-height-xx-small{max-height:4px}.max-height-x-small{max-height:8px}.max-height-small{max-height:12px}.max-height-medium{max-height:16px}.max-height-large{max-height:24px}.max-height-x-large{max-height:32px}.max-height-xx-large{max-height:40px}.max-height-xxx-large{max-height:48px}.max-height-xxxx-large{max-height:64px}.debug *{outline:1px solid gold}.flex{display:flex;flex:1}.inline-flex{display:inline-flex}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.display-block{display:block}.display-inline-block{display:inline-block}.display-inline{display:inline}.display-none{display:none}.text-decoration-none{text-decoration:none}.text-right{text-align:right}.text-left{text-align:left}.text-center{text-align:center}.margin-auto{margin-left:auto;margin-right:auto}*{box-sizing:border-box}.table{width:100%;border-collapse:collapse;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";background-color:#ffffff;border-style:solid;border-width:1px;border-color:#d1d5db;border-top:none}.table__header-cell{position:relative;text-align:left;-webkit-user-select:none;-moz-user-select:none;user-select:none;min-width:48px;font-weight:500;font-size:1rem;line-height:1.25rem;color:#ffffff;background-color:#374151;padding-top:16px;padding-bottom:16px;padding-left:8px;padding-right:8px}.table__header-cell::before,.table__header-cell::after{content:"";display:block;position:absolute;right:16px;top:50%;border:7px solid transparent}.table__header-cell::before{border-bottom-color:#6b7280;margin-top:-15px}.table__header-cell::after{border-top-color:#6b7280;margin-top:3px}.table__header-cell.desc::after{border-top-color:#f9fafb}.table__header-cell.asc::before{border-bottom-color:#f9fafb}.table__header-cell--no-sort::before,.table__header-cell--no-sort::after{border:none}.table__header-cell:not(.table__header-cell--no-sort){padding-right:46px;cursor:pointer}.table__header-cell--fit-content{white-space:nowrap;width:1px}.table__header-cell--align-left{text-align:left}.table__header-cell--align-center{text-align:center}.table__header-cell--align-right{text-align:right}.table__header-cell--sticky{position:sticky;top:0;z-index:1}.table__row:nth-child(even):hover{background-color:#f3f4f6}.table__row:nth-child(odd){background-color:#f9fafb}.table__row:nth-child(odd):hover{background-color:#f3f4f6}.table__data{font-size:1rem;padding-left:8px;padding-right:8px;height:56px;border-right:1px solid #d1d5db}.table__data:last-child{border-right:none}.table__data--fit-content{white-space:nowrap;width:1px}.table__data--align-left{text-align:left}.table__data--align-center{text-align:center}.table__data--align-right{text-align:right}.table__data--monospace-font{font-family:Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace}.empty-page{display:flex;align-items:center;flex-direction:column;margin-top:72px;height:345px}.empty-page>*{margin:0}.empty-page__header{font-size:2.25rem}.empty-page__subheader{margin-top:32px;font-size:1.5rem}`, m = class {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
s(this, e), this.selectionChanged = h(this, "selectionChanged", 7), this.columns = [], this.numberOfSelectedRows = void 0, this.rows = [], this.maxRows = void 0, this.selectable = !1, this.selected = /* @__PURE__ */ new Set(), this.emptyPageHeader = "No results found", this.emptyPageSubheader = void 0, this.isHeaderSticky = !0, this.tableRows = [], this.sortByColumn = null;
|
|
8
|
+
}
|
|
9
|
+
onSelectionChangedHandler() {
|
|
10
|
+
this.selectionChanged.emit(this.selected);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* When the rows is set from outside of the components the table sorting is reset and the rows are assigned to the internal tabelRows property.
|
|
14
|
+
*/
|
|
15
|
+
onRowsChangedHandler() {
|
|
16
|
+
this.tableRows = Array.from(this.rows), this.setHeaderCheckboxState();
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
const e = this.el.querySelectorAll("mi-column");
|
|
20
|
+
this.columns = Array.from(e).map((t) => {
|
|
21
|
+
const i = {
|
|
22
|
+
alignContent: t.alignContent,
|
|
23
|
+
monospace: t.monospace,
|
|
24
|
+
label: l(t.label) ? t.binding : t.label,
|
|
25
|
+
binding: t.binding || null,
|
|
26
|
+
sortable: t.sortable,
|
|
27
|
+
fitContent: !!t.fitContent,
|
|
28
|
+
/* All HTML comments are removed from the template to avoid the issues with the table not displaying any data in IE11 */
|
|
29
|
+
template: t.innerHTML.replace(/<!--[\s\S]*?-->/g, ""),
|
|
30
|
+
columnElement: t,
|
|
31
|
+
width: t.width
|
|
32
|
+
};
|
|
33
|
+
return t.sort && !this.sortByColumn && (this.sortByColumn = { column: i, sortOrder: t.sort === "asc" ? "asc" : "desc" }), i;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Column header click handler.
|
|
38
|
+
* If the column is sortable the sort order is reversed.
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
* @param {MouseEvent} event
|
|
42
|
+
* @param {any} column
|
|
43
|
+
*/
|
|
44
|
+
columnHeaderClickHandler(e, t) {
|
|
45
|
+
var i, a;
|
|
46
|
+
if (!l(t.sortable)) {
|
|
47
|
+
let n = "asc";
|
|
48
|
+
t === ((i = this.sortByColumn) === null || i === void 0 ? void 0 : i.column) && (n = ((a = this.sortByColumn) === null || a === void 0 ? void 0 : a.sortOrder) === "asc" ? "desc" : "asc"), this.sortByColumn = { column: t, sortOrder: n };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sorts table rows.
|
|
53
|
+
*
|
|
54
|
+
* @private
|
|
55
|
+
* @return {Array<any>}
|
|
56
|
+
*/
|
|
57
|
+
sortTableRows() {
|
|
58
|
+
var e, t, i;
|
|
59
|
+
if (this.tableRows.length > 0 && this.sortByColumn) {
|
|
60
|
+
let a;
|
|
61
|
+
const n = (e = this.sortByColumn) === null || e === void 0 ? void 0 : e.column, r = (t = this.sortByColumn) === null || t === void 0 ? void 0 : t.sortOrder;
|
|
62
|
+
if (n && r)
|
|
63
|
+
return ((i = n.sortable) === null || i === void 0 ? void 0 : i.toLowerCase()) === "date" ? a = r === "desc" ? w(n.binding) : f(n.binding) : a = r === "desc" ? u(n.binding) : x(n.binding), [...this.tableRows.sort(a)];
|
|
64
|
+
}
|
|
65
|
+
return this.tableRows;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Replace template variables (eg. "{id}") with the corresponding value from the data.
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
* @param {string} template
|
|
72
|
+
* @param {object} data
|
|
73
|
+
* @returns {string}
|
|
74
|
+
*/
|
|
75
|
+
replaceVars(e, t) {
|
|
76
|
+
return e.replace(/\{(.*?)\}/g, (i, a) => a.split(".").reduce((r, d) => r ? r[d] : null, t));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Remove boolean HTML attributes (eg. checked) that will have a false value based on data. This is necessary since
|
|
80
|
+
* the very presence of the attribute will give it a truthy value.
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
* @param {string} template
|
|
84
|
+
* @param {array} data
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
removeFalseBooleanAttributes(e, t) {
|
|
88
|
+
return e.replace(/ (checked|disabled|hidden|selected)="\{(.*?)\}"/, (i, a, n) => t[n] === !1 ? "" : a);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* React to clicks on table rows and emits the internal cellContentClicked event to
|
|
92
|
+
* the column component if clicked on content within a cell.
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
* @param {MouseEvent} event
|
|
96
|
+
* @param {any} tableRow
|
|
97
|
+
*/
|
|
98
|
+
tableRowClicked(e, t) {
|
|
99
|
+
var i;
|
|
100
|
+
const a = e.target, n = a.closest("td").cellIndex, r = this.selectable ? n - 1 : n;
|
|
101
|
+
if (a.tagName.toLowerCase() !== "td" && this.columns[r]) {
|
|
102
|
+
const d = { detail: t };
|
|
103
|
+
(i = this.columns[r]) === null || i === void 0 || i.columnElement.dispatchEvent(new CustomEvent("cellContentClicked", d));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async componentWillLoad() {
|
|
107
|
+
this.rows.length > 0 && (this.tableRows = Array.from(this.rows));
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
return o(c, null, o("table", { class: "table" }, o("thead", null, o("tr", null, this.renderSelectHeader(), this.columns.map((e) => {
|
|
111
|
+
var t;
|
|
112
|
+
const i = e.fitContent ? "" : e.width || "auto", a = ((t = this.sortByColumn) === null || t === void 0 ? void 0 : t.column) === e ? this.sortByColumn.sortOrder : null;
|
|
113
|
+
return o("th", { "data-binding": e.binding, style: { width: i, "max-width": i, "min-width": i }, onClick: (n) => this.columnHeaderClickHandler(n, e), class: `table__header-cell ${this.isHeaderSticky ? "table__header-cell--sticky" : ""} ${l(e.sortable) ? "table__header-cell--no-sort" : ""} ${l(a) ? "" : a} ${e.fitContent ? "table__header-cell--fit-content" : ""}` }, e.label);
|
|
114
|
+
}))), o("tbody", null, this.renderTableContent())), this.tableRows.length === 0 ? this.renderEmptyPage() : null);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* If the table is selectable then renderSelectHeader will render the th element with the checkbox to check or uncheck all items in the table.
|
|
118
|
+
*
|
|
119
|
+
* @private
|
|
120
|
+
* @returns {JSX.Element}
|
|
121
|
+
*/
|
|
122
|
+
renderSelectHeader() {
|
|
123
|
+
if (this.selectable)
|
|
124
|
+
return o("th", { class: `table__header-cell ${this.isHeaderSticky ? "table__header-cell--sticky" : ""} table__header-cell--fit-content table__header-cell--no-sort table__header-cell--align-center` }, o("input", { type: "checkbox", class: "mi-input", ref: (e) => this.selectAllCheckbox = e, onChange: () => this.selectHeaderOnChangeHandler() }));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* If the table is selectable then this method will render the td for each row in the item to select or unselect the row.
|
|
128
|
+
*
|
|
129
|
+
* @private
|
|
130
|
+
* @param {object} row
|
|
131
|
+
*/
|
|
132
|
+
renderSelectRow(e) {
|
|
133
|
+
if (this.selectable)
|
|
134
|
+
return o("td", { class: "table__data table__data--align-center" }, o("input", { class: "mi-input", type: "checkbox", checked: this.selected.has(e), onChange: (t) => this.selectOnChangeHandler(t, e) }));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Helper method to render the tables content.
|
|
138
|
+
*
|
|
139
|
+
* @private
|
|
140
|
+
* @return {[JSX.Element]}
|
|
141
|
+
*/
|
|
142
|
+
renderTableContent() {
|
|
143
|
+
let e = this.sortTableRows();
|
|
144
|
+
return e = b(this.maxRows) && this.maxRows > 0 ? e.slice(0, this.maxRows) : e, e.map((t) => this.renderTableRow(t));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Helper method to render a table row.
|
|
148
|
+
*
|
|
149
|
+
* @private
|
|
150
|
+
* @param {*} tableRow
|
|
151
|
+
* @return {JSX.Element}
|
|
152
|
+
*/
|
|
153
|
+
renderTableRow(e) {
|
|
154
|
+
const t = [];
|
|
155
|
+
for (const i of this.columns) {
|
|
156
|
+
let a = i.template;
|
|
157
|
+
a > "" ? (a = this.removeFalseBooleanAttributes(a, e), a = this.replaceVars(a, e), t.push(a)) : t.push(e[i.binding]);
|
|
158
|
+
}
|
|
159
|
+
return o("tr", { class: "table__row", onClick: (i) => this.tableRowClicked(i, e) }, this.renderSelectRow(e), t.map((i, a) => o("td", { class: `table__data ${this.columns[a].fitContent ? "table__data--fit-content" : ""} table__data--align-${this.columns[a].alignContent || "left"} ${this.columns[a].monospace ? "table__data--monospace-font" : ""}`, innerHTML: i })));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Renders en empty page with error message when no table rows are available.
|
|
163
|
+
*
|
|
164
|
+
* @private
|
|
165
|
+
* @returns {JSX.Element}
|
|
166
|
+
*/
|
|
167
|
+
renderEmptyPage() {
|
|
168
|
+
return o("div", { class: "empty-page" }, o("p", { class: "empty-page__header" }, this.emptyPageHeader), o("p", { class: "empty-page__subheader" }, this.emptyPageSubheader));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The event handler for the onchange event for the checkboxes in the selectable column.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @param {EventData} event
|
|
175
|
+
* @param {object} row
|
|
176
|
+
*/
|
|
177
|
+
selectOnChangeHandler(e, t) {
|
|
178
|
+
e.target.checked ? this.selected.add(t) : this.selected.delete(t), this.setHeaderCheckboxState(), this.numberOfSelectedRows = this.selected.size, e.stopPropagation();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Set the state of the checkbox in the table header.
|
|
182
|
+
* The state can be either checked, unchecked or indeterminate.
|
|
183
|
+
*/
|
|
184
|
+
setHeaderCheckboxState() {
|
|
185
|
+
this.selectAllCheckbox && this.selectable && (this.selectAllCheckbox.checked = this.selected.size === this.rows.length, this.selectAllCheckbox.indeterminate = this.selected.size > 0 && this.selected.size < this.rows.length);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The event handler for the onchange event for the checkbox in the selectable column header.
|
|
189
|
+
*
|
|
190
|
+
* @private
|
|
191
|
+
* @param {EventData} event
|
|
192
|
+
*/
|
|
193
|
+
selectHeaderOnChangeHandler() {
|
|
194
|
+
this.selected.size > 0 && this.selected.size <= this.rows.length ? (this.selected.clear(), this.selectAllCheckbox.checked = !1) : (this.rows.forEach((e) => this.selected.add(e)), this.selectAllCheckbox.checked = !0), this.numberOfSelectedRows = this.selected.size;
|
|
195
|
+
}
|
|
196
|
+
get el() {
|
|
197
|
+
return g(this);
|
|
198
|
+
}
|
|
199
|
+
static get watchers() {
|
|
200
|
+
return {
|
|
201
|
+
numberOfSelectedRows: ["onSelectionChangedHandler"],
|
|
202
|
+
rows: ["onRowsChangedHandler"]
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}, x = (e) => (t, i) => `${t[e] || ""}`.localeCompare(`${i[e] || ""}`.trimStart().toLowerCase(), void 0, { numeric: !0 }), u = (e) => (t, i) => `${i[e] || ""}`.localeCompare(`${t[e] || ""}`.trimStart().toLowerCase(), void 0, { numeric: !0 }), f = (e) => (t, i) => {
|
|
206
|
+
const a = Date.parse(t[e]), n = Date.parse(i[e]);
|
|
207
|
+
return a > n ? 1 : a < n ? -1 : 0;
|
|
208
|
+
}, w = (e) => (t, i) => {
|
|
209
|
+
const a = Date.parse(i[e]), n = Date.parse(t[e]);
|
|
210
|
+
return a > n ? 1 : a < n ? -1 : 0;
|
|
211
|
+
};
|
|
212
|
+
m.style = p;
|
|
213
|
+
export {
|
|
214
|
+
m as mi_data_table
|
|
215
|
+
};
|