@mapsindoors/map-template 1.93.2 → 1.94.0
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-982405ad.mjs → GoogleMapsMap-BqYRaFgc.mjs} +51 -62
- package/dist/MapboxMap-CUYrfLHY.mjs +34732 -0
- package/dist/_commonjsHelpers-ba3f0406.js +21 -0
- package/dist/combo-box-item.entry.js +15 -0
- package/dist/icon-b8d01d6f.js +24 -0
- package/dist/index-7e9696f3.js +1678 -0
- package/dist/index.js +1 -0
- package/dist/loader.js +18 -0
- package/dist/mapsindoors-react.es.js +3 -5
- package/dist/mapsindoors-react.umd.js +197 -582
- package/dist/mapsindoors-webcomponent.es.js +58512 -75790
- package/dist/mi-card_2.entry.js +28 -0
- package/dist/mi-chip.entry.js +22 -0
- package/dist/mi-column.entry.js +28 -0
- package/dist/mi-combo-box.entry.js +416 -0
- package/dist/mi-components.js +18 -0
- package/dist/mi-data-table.entry.js +302 -0
- package/dist/mi-distance_2.entry.js +67 -0
- package/dist/mi-dropdown-item.entry.js +15 -0
- package/dist/mi-dropdown.entry.js +610 -0
- package/dist/mi-floor-selector.entry.js +202 -0
- package/dist/mi-keyboard.entry.js +238 -0
- package/dist/mi-list-item-category.entry.js +48 -0
- package/dist/mi-list-item-location.entry.js +171 -0
- package/dist/mi-list.entry.js +56 -0
- package/dist/mi-location-booking.entry.js +5193 -0
- package/dist/mi-location-info.entry.js +63 -0
- package/dist/mi-map-googlemaps.entry.js +750 -0
- package/dist/mi-map-mapbox.entry.js +467 -0
- package/dist/mi-metric-card.entry.js +48 -0
- package/dist/mi-my-position.entry.js +986 -0
- package/dist/mi-notification.entry.js +127 -0
- package/dist/mi-route-instructions-heading.entry.js +73 -0
- package/dist/mi-route-instructions-maneuver-legacy.entry.js +82 -0
- package/dist/mi-route-instructions-maneuver.entry.js +82 -0
- package/dist/mi-route-instructions-step-legacy.entry.js +308 -0
- package/dist/mi-route-instructions-step.entry.js +321 -0
- package/dist/mi-route-instructions.entry.js +157 -0
- package/dist/mi-scroll-buttons.entry.js +112 -0
- package/dist/mi-search.entry.js +376 -0
- package/dist/mi-share-sms.entry.js +80 -0
- package/dist/mi-step-switcher.entry.js +31 -0
- package/dist/mi-tab-panel.entry.js +25 -0
- package/dist/mi-tab.entry.js +12 -0
- package/dist/mi-tabs.entry.js +47 -0
- package/dist/mi-time.entry.js +57 -0
- package/dist/mi-variables-9a6c8d4d.js +6 -0
- package/dist/polyfills/core-js.js +11 -0
- package/dist/polyfills/css-shim.js +1 -0
- package/dist/polyfills/dom.js +79 -0
- package/dist/polyfills/es5-html-element.js +1 -0
- package/dist/polyfills/index.js +34 -0
- package/dist/polyfills/system.js +6 -0
- package/dist/{reactcomponent-7fbbd9b2.mjs → reactcomponent-DTepe7hB.mjs} +14121 -14626
- package/dist/route-travel-mode.enum-7f4ce9c7.js +9 -0
- package/dist/sort-order.enum-64ce8998.js +552 -0
- package/dist/unit-system.enum-eaefb53e.js +7 -0
- package/dist/utils-ae714467.js +61 -0
- package/package.json +10 -6
- package/dist/MapboxMap-06ef82a3.mjs +0 -37815
- package/dist/_commonjsHelpers-ba3f0406-b96e6d6a.mjs +0 -22
- package/dist/combo-box-item.entry-d35f3d51.mjs +0 -15
- package/dist/icon-b8d01d6f-ddfa2c17.mjs +0 -25
- package/dist/mapsindoors-webcomponent.umd.js +0 -3245
- package/dist/mi-card_2.entry-fc772c35.mjs +0 -26
- package/dist/mi-chip.entry-81c742a1.mjs +0 -19
- package/dist/mi-column.entry-3a083282.mjs +0 -21
- package/dist/mi-combo-box.entry-cae6401a.mjs +0 -263
- package/dist/mi-data-table.entry-d4c3f445.mjs +0 -224
- package/dist/mi-distance_2.entry-a33ed69a.mjs +0 -339
- package/dist/mi-dropdown-item.entry-974d1e4f.mjs +0 -15
- package/dist/mi-dropdown.entry-5317db65.mjs +0 -349
- package/dist/mi-floor-selector.entry-185fbd8b.mjs +0 -115
- package/dist/mi-keyboard.entry-eaf4b9ef.mjs +0 -3103
- package/dist/mi-list-item-category.entry-9c95008c.mjs +0 -39
- package/dist/mi-list-item-location.entry-8b41e8f0.mjs +0 -137
- package/dist/mi-list.entry-1218d29d.mjs +0 -42
- package/dist/mi-location-booking.entry-270aaf5a.mjs +0 -4866
- package/dist/mi-location-info.entry-e4f7fd04.mjs +0 -32
- package/dist/mi-map-googlemaps.entry-81fa28d2.mjs +0 -467
- package/dist/mi-map-mapbox.entry-31821da3.mjs +0 -301
- package/dist/mi-metric-card.entry-40407f04.mjs +0 -29
- package/dist/mi-my-position.entry-bc48fe6e.mjs +0 -703
- package/dist/mi-notification.entry-9a2bc53b.mjs +0 -84
- package/dist/mi-route-instructions-heading.entry-e5b1ff04.mjs +0 -75
- package/dist/mi-route-instructions-maneuver-legacy.entry-2c3d73ab.mjs +0 -76
- package/dist/mi-route-instructions-maneuver.entry-c6f01024.mjs +0 -76
- package/dist/mi-route-instructions-step-legacy.entry-80bcf097.mjs +0 -202
- package/dist/mi-route-instructions-step.entry-db802e13.mjs +0 -231
- package/dist/mi-route-instructions.entry-62416e29.mjs +0 -143
- package/dist/mi-scroll-buttons.entry-92b62b21.mjs +0 -83
- package/dist/mi-search.entry-87f1e64a.mjs +0 -251
- package/dist/mi-share-sms.entry-b6725edb.mjs +0 -56
- package/dist/mi-step-switcher.entry-f8f6c040.mjs +0 -27
- package/dist/mi-tab-panel.entry-a89213c2.mjs +0 -22
- package/dist/mi-tab.entry-a2fb3f8c.mjs +0 -14
- package/dist/mi-tabs.entry-cd638ea7.mjs +0 -37
- package/dist/mi-time.entry-0b02870d.mjs +0 -46
- package/dist/mi-variables-9a6c8d4d-e06eec88.mjs +0 -8
- package/dist/route-travel-mode.enum-7f4ce9c7-a9c95a83.mjs +0 -8
- package/dist/sort-order.enum-64ce8998-b75ac596.mjs +0 -318
- package/dist/unit-system.enum-eaefb53e-0f424da4.mjs +0 -8
- package/dist/utils-ae714467-b07fc3be.mjs +0 -37
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-7e9696f3.js';
|
|
2
|
+
import { i as isNullOrUndefined, a as isNumber } from './utils-ae714467.js';
|
|
3
|
+
|
|
4
|
+
const dataTableCss = "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}";
|
|
5
|
+
|
|
6
|
+
const DataTable = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.selectionChanged = createEvent(this, "selectionChanged", 7);
|
|
10
|
+
this.columns = [];
|
|
11
|
+
this.numberOfSelectedRows = undefined;
|
|
12
|
+
this.rows = [];
|
|
13
|
+
this.maxRows = undefined;
|
|
14
|
+
this.page = undefined;
|
|
15
|
+
this.selectable = false;
|
|
16
|
+
this.selected = new Set();
|
|
17
|
+
this.emptyPageHeader = 'No results found';
|
|
18
|
+
this.emptyPageSubheader = undefined;
|
|
19
|
+
this.isHeaderSticky = true;
|
|
20
|
+
this.tableRows = [];
|
|
21
|
+
this.currentPage = 1;
|
|
22
|
+
this.sortByColumn = null;
|
|
23
|
+
}
|
|
24
|
+
onSelectionChangedHandler() {
|
|
25
|
+
this.selectionChanged.emit(this.selected);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 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.
|
|
29
|
+
*/
|
|
30
|
+
onRowsChangedHandler() {
|
|
31
|
+
this.tableRows = Array.from(this.rows);
|
|
32
|
+
this.setHeaderCheckboxState();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* When the page is set from outside of the components the table needs to show the newly specified page of rows.
|
|
36
|
+
*/
|
|
37
|
+
onPageChangedHandler() {
|
|
38
|
+
this.currentPage = this.page;
|
|
39
|
+
this.renderTableContent();
|
|
40
|
+
}
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
const miColumns = this.el.querySelectorAll('mi-column');
|
|
43
|
+
this.columns = Array.from(miColumns).map((miColumn) => {
|
|
44
|
+
const column = {
|
|
45
|
+
alignContent: miColumn.alignContent,
|
|
46
|
+
monospace: miColumn.monospace,
|
|
47
|
+
label: !isNullOrUndefined(miColumn.label) ? miColumn.label : miColumn.binding,
|
|
48
|
+
binding: miColumn.binding || null,
|
|
49
|
+
sortable: miColumn.sortable,
|
|
50
|
+
fitContent: !!miColumn.fitContent,
|
|
51
|
+
/* All HTML comments are removed from the template to avoid the issues with the table not displaying any data in IE11 */
|
|
52
|
+
template: miColumn.innerHTML.replace(/<!--[\s\S]*?-->/g, ''),
|
|
53
|
+
columnElement: miColumn,
|
|
54
|
+
width: miColumn.width
|
|
55
|
+
};
|
|
56
|
+
/* If the mi-column has the sort attribute, then the initial sort state is set. */
|
|
57
|
+
if (miColumn.sort && !this.sortByColumn) {
|
|
58
|
+
this.sortByColumn = { column: column, sortOrder: miColumn.sort === 'asc' ? 'asc' : 'desc' };
|
|
59
|
+
}
|
|
60
|
+
return column;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Column header click handler.
|
|
65
|
+
* If the column is sortable the sort order is reversed.
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
* @param {MouseEvent} event
|
|
69
|
+
* @param {any} column
|
|
70
|
+
*/
|
|
71
|
+
columnHeaderClickHandler(event, column) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
if (!isNullOrUndefined(column.sortable)) {
|
|
74
|
+
let sortOrder = 'asc';
|
|
75
|
+
if (column === ((_a = this.sortByColumn) === null || _a === void 0 ? void 0 : _a.column)) {
|
|
76
|
+
// TODO: Use SortOrder enum in MICMS-1353
|
|
77
|
+
sortOrder = ((_b = this.sortByColumn) === null || _b === void 0 ? void 0 : _b.sortOrder) === 'asc' ? 'desc' : 'asc';
|
|
78
|
+
}
|
|
79
|
+
/* When a column that is sortable is clicked then the sort state is updated. */
|
|
80
|
+
this.sortByColumn = { column: column, sortOrder: sortOrder };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sorts table rows.
|
|
85
|
+
*
|
|
86
|
+
* @private
|
|
87
|
+
* @return {Array<any>}
|
|
88
|
+
*/
|
|
89
|
+
sortTableRows() {
|
|
90
|
+
var _a, _b, _c;
|
|
91
|
+
//Check if the table has any rows.
|
|
92
|
+
if (this.tableRows.length > 0 && this.sortByColumn) {
|
|
93
|
+
let sortMethod;
|
|
94
|
+
const sortByColumn = (_a = this.sortByColumn) === null || _a === void 0 ? void 0 : _a.column;
|
|
95
|
+
const sortOrder = (_b = this.sortByColumn) === null || _b === void 0 ? void 0 : _b.sortOrder;
|
|
96
|
+
if (sortByColumn && sortOrder) {
|
|
97
|
+
if (((_c = sortByColumn.sortable) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'date') {
|
|
98
|
+
sortMethod = sortOrder === 'desc' ? dateDesc(sortByColumn.binding) : dateAsc(sortByColumn.binding);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
sortMethod = sortOrder === 'desc' ? desc(sortByColumn.binding) : asc(sortByColumn.binding);
|
|
102
|
+
}
|
|
103
|
+
return [...this.tableRows.sort(sortMethod)];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return this.tableRows;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Replace template variables (eg. "{id}") with the corresponding value from the data.
|
|
110
|
+
*
|
|
111
|
+
* @private
|
|
112
|
+
* @param {string} template
|
|
113
|
+
* @param {object} data
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
replaceVars(template, data) {
|
|
117
|
+
return template.replace(/\{(.*?)\}/g, (match, capture) => {
|
|
118
|
+
const path = capture.split('.');
|
|
119
|
+
// Traverse the input object until a given key is found.
|
|
120
|
+
return path.reduce((object, key) => {
|
|
121
|
+
return object ? object[key] : null;
|
|
122
|
+
}, data);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Remove boolean HTML attributes (eg. checked) that will have a false value based on data. This is necessary since
|
|
127
|
+
* the very presence of the attribute will give it a truthy value.
|
|
128
|
+
*
|
|
129
|
+
* @private
|
|
130
|
+
* @param {string} template
|
|
131
|
+
* @param {array} data
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
removeFalseBooleanAttributes(template, data) {
|
|
135
|
+
return template.replace(/ (checked|disabled|hidden|selected)="\{(.*?)\}"/, (match, attributeName, binding) => {
|
|
136
|
+
return data[binding] === false ? '' : attributeName;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* React to clicks on table rows and emits the internal cellContentClicked event to
|
|
141
|
+
* the column component if clicked on content within a cell.
|
|
142
|
+
*
|
|
143
|
+
* @private
|
|
144
|
+
* @param {MouseEvent} event
|
|
145
|
+
* @param {any} tableRow
|
|
146
|
+
*/
|
|
147
|
+
tableRowClicked(event, tableRow) {
|
|
148
|
+
var _a;
|
|
149
|
+
const element = event.target;
|
|
150
|
+
const cellIndex = element.closest('td').cellIndex;
|
|
151
|
+
const columnClickedIndex = this.selectable ? cellIndex - 1 : cellIndex;
|
|
152
|
+
if (element.tagName.toLowerCase() !== 'td' && this.columns[columnClickedIndex]) {
|
|
153
|
+
const eventPayload = { detail: tableRow };
|
|
154
|
+
(_a = this.columns[columnClickedIndex]) === null || _a === void 0 ? void 0 : _a.columnElement.dispatchEvent(new CustomEvent('cellContentClicked', eventPayload));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async componentWillLoad() {
|
|
158
|
+
if (this.rows.length > 0) {
|
|
159
|
+
this.tableRows = Array.from(this.rows);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
render() {
|
|
163
|
+
return (h(Host, null, h("table", { class: "table" }, h("thead", null, h("tr", null, this.renderSelectHeader(), this.columns.map(column => {
|
|
164
|
+
var _a;
|
|
165
|
+
const width = !column.fitContent ? column.width || 'auto' : '';
|
|
166
|
+
const sortOrder = ((_a = this.sortByColumn) === null || _a === void 0 ? void 0 : _a.column) === column ? this.sortByColumn.sortOrder : null;
|
|
167
|
+
return h("th", { "data-binding": column.binding, style: { 'width': width, 'max-width': width, 'min-width': width }, onClick: (event) => this.columnHeaderClickHandler(event, column), class: `table__header-cell ${this.isHeaderSticky ? 'table__header-cell--sticky' : ''} ${isNullOrUndefined(column.sortable) ? 'table__header-cell--no-sort' : ''} ${isNullOrUndefined(sortOrder) ? '' : sortOrder} ${column.fitContent ? 'table__header-cell--fit-content' : ''}` }, column.label);
|
|
168
|
+
}))), h("tbody", null, this.renderTableContent())), this.tableRows.length === 0 ? this.renderEmptyPage() : null));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* If the table is selectable then renderSelectHeader will render the th element with the checkbox to check or uncheck all items in the table.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @returns {JSX.Element}
|
|
175
|
+
*/
|
|
176
|
+
renderSelectHeader() {
|
|
177
|
+
if (this.selectable) {
|
|
178
|
+
return (h("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` }, h("input", { type: "checkbox", class: "mi-input", ref: (el) => this.selectAllCheckbox = el, onChange: () => this.selectHeaderOnChangeHandler() })));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* If the table is selectable then this method will render the td for each row in the item to select or unselect the row.
|
|
183
|
+
*
|
|
184
|
+
* @private
|
|
185
|
+
* @param {object} row
|
|
186
|
+
* @returns {JSX.Element}
|
|
187
|
+
*/
|
|
188
|
+
renderSelectRow(row) {
|
|
189
|
+
if (this.selectable) {
|
|
190
|
+
return (h("td", { class: "table__data table__data--align-center" }, h("input", { class: "mi-input", type: "checkbox", checked: this.selected.has(row), onChange: event => this.selectOnChangeHandler(event, row) })));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Helper method to render the tables content.
|
|
195
|
+
*
|
|
196
|
+
* @private
|
|
197
|
+
* @returns {[JSX.Element]}
|
|
198
|
+
*/
|
|
199
|
+
renderTableContent() {
|
|
200
|
+
let tableRows = this.sortTableRows();
|
|
201
|
+
tableRows = isNumber(this.maxRows) && this.maxRows > 0 ?
|
|
202
|
+
tableRows.slice(this.maxRows * (this.currentPage - 1), this.maxRows * this.currentPage)
|
|
203
|
+
: tableRows;
|
|
204
|
+
return tableRows.map(row => this.renderTableRow(row));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Helper method to render a table row.
|
|
208
|
+
*
|
|
209
|
+
* @private
|
|
210
|
+
* @param {*} tableRow
|
|
211
|
+
* @returns {JSX.Element}
|
|
212
|
+
*/
|
|
213
|
+
renderTableRow(tableRow) {
|
|
214
|
+
const rowData = [];
|
|
215
|
+
for (const column of this.columns) {
|
|
216
|
+
let template = column.template;
|
|
217
|
+
if (template > '') {
|
|
218
|
+
template = this.removeFalseBooleanAttributes(template, tableRow);
|
|
219
|
+
template = this.replaceVars(template, tableRow);
|
|
220
|
+
rowData.push(template);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
rowData.push(tableRow[column.binding]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return h("tr", { class: "table__row", onClick: e => this.tableRowClicked(e, tableRow) }, this.renderSelectRow(tableRow), rowData.map((cellContent, cellIndex) => h("td", { class: `table__data ${this.columns[cellIndex].fitContent ? 'table__data--fit-content' : ''} table__data--align-${this.columns[cellIndex].alignContent || 'left'} ${this.columns[cellIndex].monospace ? 'table__data--monospace-font' : ''}`, innerHTML: cellContent })));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Renders en empty page with error message when no table rows are available.
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
* @returns {JSX.Element}
|
|
233
|
+
*/
|
|
234
|
+
renderEmptyPage() {
|
|
235
|
+
const emptyPage = (h("div", { class: "empty-page" }, h("p", { class: "empty-page__header" }, this.emptyPageHeader), h("p", { class: "empty-page__subheader" }, this.emptyPageSubheader)));
|
|
236
|
+
return emptyPage;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The event handler for the onchange event for the checkboxes in the selectable column.
|
|
240
|
+
*
|
|
241
|
+
* @private
|
|
242
|
+
* @param {EventData} event
|
|
243
|
+
* @param {object} row
|
|
244
|
+
*/
|
|
245
|
+
selectOnChangeHandler(event, row) {
|
|
246
|
+
event.target.checked ? this.selected.add(row) : this.selected.delete(row);
|
|
247
|
+
this.setHeaderCheckboxState();
|
|
248
|
+
//The selectedRows is updated to force a rerendering of the table with the correct state.
|
|
249
|
+
this.numberOfSelectedRows = this.selected.size;
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Set the state of the checkbox in the table header.
|
|
254
|
+
* The state can be either checked, unchecked or indeterminate.
|
|
255
|
+
*/
|
|
256
|
+
setHeaderCheckboxState() {
|
|
257
|
+
if (this.selectAllCheckbox && this.selectable) {
|
|
258
|
+
this.selectAllCheckbox.checked = this.selected.size === this.rows.length;
|
|
259
|
+
this.selectAllCheckbox.indeterminate = this.selected.size > 0 && this.selected.size < this.rows.length;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The event handler for the onchange event for the checkbox in the selectable column header.
|
|
264
|
+
*
|
|
265
|
+
* @private
|
|
266
|
+
* @param {EventData} event
|
|
267
|
+
*/
|
|
268
|
+
selectHeaderOnChangeHandler() {
|
|
269
|
+
if (this.selected.size > 0 && this.selected.size <= this.rows.length) {
|
|
270
|
+
this.selected.clear();
|
|
271
|
+
this.selectAllCheckbox.checked = false;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
this.rows.forEach(row => this.selected.add(row));
|
|
275
|
+
this.selectAllCheckbox.checked = true;
|
|
276
|
+
}
|
|
277
|
+
this.numberOfSelectedRows = this.selected.size;
|
|
278
|
+
}
|
|
279
|
+
get el() { return getElement(this); }
|
|
280
|
+
static get watchers() { return {
|
|
281
|
+
"numberOfSelectedRows": ["onSelectionChangedHandler"],
|
|
282
|
+
"rows": ["onRowsChangedHandler"],
|
|
283
|
+
"page": ["onPageChangedHandler"]
|
|
284
|
+
}; }
|
|
285
|
+
};
|
|
286
|
+
const asc = (value) => (a, b) => `${a[value] || ''}`
|
|
287
|
+
.localeCompare(`${(b[value] || '')}`.trimStart().toLowerCase(), undefined, { numeric: true });
|
|
288
|
+
const desc = (value) => (a, b) => `${b[value] || ''}`
|
|
289
|
+
.localeCompare(`${(a[value] || '')}`.trimStart().toLowerCase(), undefined, { numeric: true });
|
|
290
|
+
const dateAsc = (value) => (a, b) => {
|
|
291
|
+
const aAsDate = Date.parse(a[value]);
|
|
292
|
+
const bAsDate = Date.parse(b[value]);
|
|
293
|
+
return aAsDate > bAsDate ? 1 : aAsDate < bAsDate ? -1 : 0;
|
|
294
|
+
};
|
|
295
|
+
const dateDesc = (value) => (b, a) => {
|
|
296
|
+
const aAsDate = Date.parse(a[value]);
|
|
297
|
+
const bAsDate = Date.parse(b[value]);
|
|
298
|
+
return aAsDate > bAsDate ? 1 : aAsDate < bAsDate ? -1 : 0;
|
|
299
|
+
};
|
|
300
|
+
DataTable.style = dataTableCss;
|
|
301
|
+
|
|
302
|
+
export { DataTable as mi_data_table };
|