@mapsindoors/map-template 1.95.1 → 1.95.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/{GoogleMapsMap-C5n6Bgtp.mjs → GoogleMapsMap-Dkn60-_e.mjs} +2 -2
  2. package/dist/{MapboxMap-UCqzt1AC.mjs → MapboxMap-B1oo7IUm.mjs} +2 -2
  3. package/dist/_commonjsHelpers-B85MJLTf.js +5 -0
  4. package/dist/app-globals-DQuL1Twl.js +3 -0
  5. package/dist/combo-box-item.entry.js +8 -10
  6. package/dist/icon-DT_sDkmK.js +11 -0
  7. package/dist/index-BZQHyS7V.js +1701 -0
  8. package/dist/loader.js +7 -14
  9. package/dist/mapsindoors-react.es.js +1 -1
  10. package/dist/mapsindoors-react.umd.js +175 -175
  11. package/dist/mapsindoors-webcomponent.es.js +2916 -2904
  12. package/dist/mi-card_2.entry.js +23 -18
  13. package/dist/mi-chip.entry.js +25 -16
  14. package/dist/mi-column.entry.js +47 -23
  15. package/dist/mi-combo-box.entry.js +412 -379
  16. package/dist/mi-components.js +15 -12
  17. package/dist/mi-data-table.entry.js +298 -278
  18. package/dist/mi-distance_2.entry.js +58 -56
  19. package/dist/mi-dropdown-item.entry.js +8 -10
  20. package/dist/mi-dropdown.entry.js +525 -481
  21. package/dist/mi-floor-selector.entry.js +183 -180
  22. package/dist/mi-keyboard.entry.js +207 -186
  23. package/dist/mi-list-item-category.entry.js +44 -41
  24. package/dist/mi-list-item-location.entry.js +168 -162
  25. package/dist/mi-list.entry.js +56 -48
  26. package/dist/mi-location-booking.entry.js +320 -295
  27. package/dist/mi-location-info.entry.js +61 -53
  28. package/dist/mi-map-googlemaps.entry.js +369 -324
  29. package/dist/mi-map-mapbox.entry.js +502 -439
  30. package/dist/mi-metric-card.entry.js +50 -37
  31. package/dist/mi-my-position.entry.js +2341 -874
  32. package/dist/mi-notification.entry.js +112 -102
  33. package/dist/mi-route-instructions-heading.entry.js +70 -65
  34. package/dist/mi-route-instructions-maneuver-legacy.entry.js +80 -76
  35. package/dist/mi-route-instructions-maneuver.entry.js +80 -76
  36. package/dist/mi-route-instructions-step-legacy.entry.js +296 -282
  37. package/dist/mi-route-instructions-step.entry.js +313 -292
  38. package/dist/mi-route-instructions.entry.js +167 -150
  39. package/dist/mi-scroll-buttons.entry.js +104 -98
  40. package/dist/mi-search.entry.js +366 -325
  41. package/dist/mi-share-sms.entry.js +82 -70
  42. package/dist/mi-step-switcher.entry.js +34 -25
  43. package/dist/mi-tab-panel.entry.js +18 -18
  44. package/dist/mi-tab.entry.js +5 -7
  45. package/dist/mi-tabs.entry.js +42 -40
  46. package/dist/mi-time.entry.js +49 -49
  47. package/dist/mi-variables-CDNvnTkH.js +5 -0
  48. package/dist/{reactcomponent-DQsjxRIN.mjs → reactcomponent-2Oa1vSiK.mjs} +8996 -8660
  49. package/dist/route-travel-mode.enum-BvqP1fpw.js +9 -0
  50. package/dist/sort-order.enum-jsLAbYWg.js +566 -0
  51. package/dist/{unit-system.enum-eaefb53e.js → unit-system.enum-BwPgAWqL.js} +2 -2
  52. package/dist/utils-DNHzysQ6.js +61 -0
  53. package/package.json +1 -1
  54. package/dist/_commonjsHelpers-ba3f0406.js +0 -21
  55. package/dist/icon-b8d01d6f.js +0 -24
  56. package/dist/index-7e9696f3.js +0 -1678
  57. package/dist/mi-variables-9a6c8d4d.js +0 -6
  58. package/dist/polyfills/core-js.js +0 -11
  59. package/dist/polyfills/css-shim.js +0 -1
  60. package/dist/polyfills/dom.js +0 -79
  61. package/dist/polyfills/es5-html-element.js +0 -1
  62. package/dist/polyfills/index.js +0 -34
  63. package/dist/polyfills/system.js +0 -6
  64. package/dist/route-travel-mode.enum-7f4ce9c7.js +0 -9
  65. package/dist/sort-order.enum-64ce8998.js +0 -552
  66. package/dist/utils-ae714467.js +0 -61
@@ -1,376 +1,417 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host } from './index-7e9696f3.js';
2
- import { c as createCommonjsModule, g as getDefaultExportFromCjs } from './_commonjsHelpers-ba3f0406.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host } from './index-BZQHyS7V.js';
2
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers-B85MJLTf.js';
3
3
 
4
- var Debounce$1 = createCommonjsModule(function (module, exports) {
4
+ var dist = {};
5
5
 
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- exports["default"] = outerDecorator;
10
- exports.debounce = debounce;
11
- var DEFAULT_DEBOUNCE_DURATION = 500;
6
+ var Debounce$1 = {};
12
7
 
13
- exports.DEFAULT_DEBOUNCE_DURATION = DEFAULT_DEBOUNCE_DURATION;
14
- /** Decorates a class method so that it is debounced by the specified duration */
8
+ var hasRequiredDebounce;
15
9
 
16
- function outerDecorator(duration) {
17
- return function innerDecorator(target, key, descriptor) {
18
- return {
19
- configurable: true,
20
- enumerable: descriptor.enumerable,
21
- get: function getter() {
22
- // Attach this function to the instance (not the class)
23
- Object.defineProperty(this, key, {
24
- configurable: true,
25
- enumerable: descriptor.enumerable,
26
- value: debounce(descriptor.value, duration)
27
- });
10
+ function requireDebounce () {
11
+ if (hasRequiredDebounce) return Debounce$1;
12
+ hasRequiredDebounce = 1;
13
+ (function (exports) {
28
14
 
29
- return this[key];
30
- }
31
- };
32
- };
33
- }
15
+ Object.defineProperty(exports, "__esModule", {
16
+ value: true
17
+ });
18
+ exports["default"] = outerDecorator;
19
+ exports.debounce = debounce;
20
+ var DEFAULT_DEBOUNCE_DURATION = 500;
34
21
 
35
- /** Debounces the specified function and returns a wrapper function */
22
+ exports.DEFAULT_DEBOUNCE_DURATION = DEFAULT_DEBOUNCE_DURATION;
23
+ /** Decorates a class method so that it is debounced by the specified duration */
36
24
 
37
- function debounce(method) {
38
- var duration = arguments.length <= 1 || arguments[1] === undefined ? DEFAULT_DEBOUNCE_DURATION : arguments[1];
25
+ function outerDecorator(duration) {
26
+ return function innerDecorator(target, key, descriptor) {
27
+ return {
28
+ configurable: true,
29
+ enumerable: descriptor.enumerable,
30
+ get: function getter() {
31
+ // Attach this function to the instance (not the class)
32
+ Object.defineProperty(this, key, {
33
+ configurable: true,
34
+ enumerable: descriptor.enumerable,
35
+ value: debounce(descriptor.value, duration)
36
+ });
39
37
 
40
- var timeoutId = undefined;
38
+ return this[key];
39
+ }
40
+ };
41
+ };
42
+ }
41
43
 
42
- function debounceWrapper() {
43
- var _this = this;
44
+ /** Debounces the specified function and returns a wrapper function */
44
45
 
45
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
46
- args[_key] = arguments[_key];
47
- }
46
+ function debounce(method) {
47
+ var duration = arguments.length <= 1 || arguments[1] === undefined ? DEFAULT_DEBOUNCE_DURATION : arguments[1];
48
48
 
49
- debounceWrapper.clear();
49
+ var timeoutId = undefined;
50
50
 
51
- timeoutId = setTimeout(function () {
52
- timeoutId = null;
53
- method.apply(_this, args);
54
- }, duration);
55
- }
51
+ function debounceWrapper() {
52
+ var _this = this;
56
53
 
57
- debounceWrapper.clear = function () {
58
- if (timeoutId) {
59
- clearTimeout(timeoutId);
60
- timeoutId = null;
61
- }
62
- };
54
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
55
+ args[_key] = arguments[_key];
56
+ }
57
+
58
+ debounceWrapper.clear();
59
+
60
+ timeoutId = setTimeout(function () {
61
+ timeoutId = null;
62
+ method.apply(_this, args);
63
+ }, duration);
64
+ }
65
+
66
+ debounceWrapper.clear = function () {
67
+ if (timeoutId) {
68
+ clearTimeout(timeoutId);
69
+ timeoutId = null;
70
+ }
71
+ };
63
72
 
64
- return debounceWrapper;
73
+ return debounceWrapper;
74
+ }
75
+ } (Debounce$1));
76
+ return Debounce$1;
65
77
  }
66
- });
67
78
 
68
- var dist = createCommonjsModule(function (module, exports) {
79
+ var hasRequiredDist;
69
80
 
70
- Object.defineProperty(exports, '__esModule', {
71
- value: true
72
- });
81
+ function requireDist () {
82
+ if (hasRequiredDist) return dist;
83
+ hasRequiredDist = 1;
84
+ (function (exports) {
73
85
 
74
- function _interopExportWildcard(obj, defaults) { var newObj = defaults({}, obj); delete newObj['default']; return newObj; }
86
+ Object.defineProperty(exports, '__esModule', {
87
+ value: true
88
+ });
75
89
 
76
- function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
90
+ function _interopExportWildcard(obj, defaults) { var newObj = defaults({}, obj); delete newObj['default']; return newObj; }
77
91
 
78
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
92
+ function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
79
93
 
94
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
80
95
 
96
+ var _DebounceJs = requireDebounce();
81
97
 
82
- var _DebounceJs2 = _interopRequireDefault(Debounce$1);
98
+ var _DebounceJs2 = _interopRequireDefault(_DebounceJs);
83
99
 
84
- exports['default'] = _DebounceJs2['default'];
100
+ exports['default'] = _DebounceJs2['default'];
85
101
 
86
- _defaults(exports, _interopExportWildcard(Debounce$1, _defaults));
87
- });
102
+ _defaults(exports, _interopExportWildcard(_DebounceJs, _defaults));
103
+ } (dist));
104
+ return dist;
105
+ }
88
106
 
89
- const Debounce = /*@__PURE__*/getDefaultExportFromCjs(dist);
107
+ var distExports = requireDist();
108
+ var Debounce = /*@__PURE__*/getDefaultExportFromCjs(distExports);
90
109
 
91
- const searchCss = "@charset \"UTF-8\";mi-search{display:block;position:relative;}mi-search input[type=search]{border-radius:8px;background-color:#ffffff;padding-left:2.5rem;min-height:3rem;height:auto;font-size:1rem;padding-right:2.5rem;font-family:-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\";-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;position:relative;background-image:url(\"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMS43MSAxMUgxMi41TDE3LjQ5IDE2TDE2IDE3LjQ5TDExIDEyLjVWMTEuNzFMMTAuNzMgMTEuNDNDOS41OSAxMi40MSA4LjExIDEzIDYuNSAxM0MyLjkxIDEzIDAgMTAuMDkgMCA2LjVDMCAyLjkxIDIuOTEgMCA2LjUgMEMxMC4wOSAwIDEzIDIuOTEgMTMgNi41QzEzIDguMTEgMTIuNDEgOS41OSAxMS40MyAxMC43M0wxMS43MSAxMVpNMiA2LjVDMiA4Ljk5IDQuMDEgMTEgNi41IDExQzguOTkgMTEgMTEgOC45OSAxMSA2LjVDMTEgNC4wMSA4Ljk5IDIgNi41IDJDNC4wMSAyIDIgNC4wMSAyIDYuNVoiIGZpbGw9IiM4RDk4QUEiLz4KPC9zdmc+Cg==\");background-repeat:no-repeat;background-position:1rem center;background-size:1.125rem 1.125rem;border-color:#E6E6E6;color:var(--tailwind-colors-neutral-500);border:1px solid var(--tailwind-colors-gray-200)}mi-search input[type=search]:-moz-placeholder-shown{padding-right:0.875rem}mi-search input[type=search]:placeholder-shown{padding-right:0.875rem}mi-search input[type=search]:focus{border-color:#3b82f6;box-shadow:0 0 0 2px #cfe0fc;}mi-search input[type=search][disabled]{pointer-events:none}mi-search input::-webkit-search-cancel-button{-webkit-appearance:none}mi-search input::-ms-clear{display:none}mi-search input::-moz-search-clear-button{-moz-appearance:none}mi-search button{position:absolute;right:0.875rem;top:50%;transform:translateY(-50%);width:1.25rem;height:1.25rem;background-color:#6b7280;border-radius:50%;padding:0;border-width:0;display:flex;align-items:center;justify-content:center}mi-search button:focus{outline:0}mi-search button svg{fill:white;width:0.625rem;height:0.625rem}";
110
+ const searchCss = () => `@charset "UTF-8";mi-search{display:block;position:relative;}mi-search input[type=search]{border-radius:8px;background-color:#ffffff;padding-left:2.5rem;min-height:3rem;height:auto;font-size:1rem;padding-right:2.5rem;font-family:-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";-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;position:relative;background-image:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMS43MSAxMUgxMi41TDE3LjQ5IDE2TDE2IDE3LjQ5TDExIDEyLjVWMTEuNzFMMTAuNzMgMTEuNDNDOS41OSAxMi40MSA4LjExIDEzIDYuNSAxM0MyLjkxIDEzIDAgMTAuMDkgMCA2LjVDMCAyLjkxIDIuOTEgMCA2LjUgMEMxMC4wOSAwIDEzIDIuOTEgMTMgNi41QzEzIDguMTEgMTIuNDEgOS41OSAxMS40MyAxMC43M0wxMS43MSAxMVpNMiA2LjVDMiA4Ljk5IDQuMDEgMTEgNi41IDExQzguOTkgMTEgMTEgOC45OSAxMSA2LjVDMTEgNC4wMSA4Ljk5IDIgNi41IDJDNC4wMSAyIDIgNC4wMSAyIDYuNVoiIGZpbGw9IiM4RDk4QUEiLz4KPC9zdmc+Cg==");background-repeat:no-repeat;background-position:1rem center;background-size:1.125rem 1.125rem;border-color:#E6E6E6;color:var(--tailwind-colors-neutral-500);border:1px solid var(--tailwind-colors-gray-200)}mi-search input[type=search]:-moz-placeholder-shown{padding-right:0.875rem}mi-search input[type=search]:placeholder-shown{padding-right:0.875rem}mi-search input[type=search]:focus{border-color:#3b82f6;box-shadow:0 0 0 2px #cfe0fc;}mi-search input[type=search][disabled]{pointer-events:none}mi-search input::-webkit-search-cancel-button{-webkit-appearance:none}mi-search input::-ms-clear{display:none}mi-search input::-moz-search-clear-button{-moz-appearance:none}mi-search button{position:absolute;right:0.875rem;top:50%;transform:translateY(-50%);width:1.25rem;height:1.25rem;background-color:#6b7280;border-radius:50%;padding:0;border-width:0;display:flex;align-items:center;justify-content:center}mi-search button:focus{outline:0}mi-search button svg{fill:white;width:0.625rem;height:0.625rem}`;
92
111
 
93
112
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
94
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
95
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
96
- r = Reflect.decorate(decorators, target, key, desc);
97
- else
98
- for (var i = decorators.length - 1; i >= 0; i--)
99
- if (d = decorators[i])
100
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
101
- return c > 3 && r && Object.defineProperty(target, key, r), r;
113
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
114
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
115
+ r = Reflect.decorate(decorators, target, key, desc);
116
+ else
117
+ for (var i = decorators.length - 1; i >= 0; i--)
118
+ if (d = decorators[i])
119
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
120
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
102
121
  };
103
122
  const Search = class {
104
- constructor(hostRef) {
105
- registerInstance(this, hostRef);
106
- this.results = createEvent(this, "results", 7);
107
- this.cleared = createEvent(this, "cleared", 7);
108
- this.componentRendered = createEvent(this, "componentRendered", 7);
109
- this.shortInput = createEvent(this, "shortInput", 7);
110
- this.changed = createEvent(this, "changed", 7);
111
- /**
112
- * Sets the prevention of the search.
113
- */
114
- this.preventSearch = false;
115
- this.placeholder = '';
116
- this.idAttribute = '';
117
- this.dataAttributes = {};
118
- this.mapsindoors = false;
119
- this.google = false;
120
- this.mapbox = false;
121
- this.language = 'en';
122
- this.miFields = 'name,description,aliases,categories,externalId';
123
- this.miTake = undefined;
124
- this.miSkip = undefined;
125
- this.miOrder = undefined;
126
- this.miCategories = undefined;
127
- this.miNear = undefined;
128
- this.miVenue = undefined;
129
- this.gmCountryCode = undefined;
130
- this.value = undefined;
131
- this.disabled = false;
132
- this.sessionToken = undefined;
133
- this.userPosition = undefined;
134
- }
135
- valueChange(newValue) {
136
- if (!newValue || !this.inputElement) {
137
- return;
138
- }
139
- if (newValue !== this.inputElement.value) {
140
- // If newValue is different from what is in the input element, we know it's set from outside the component.
141
- this.inputElement.value = newValue;
142
- if (!this.preventSearch) {
143
- this.inputChanged();
144
- }
123
+ constructor(hostRef) {
124
+ registerInstance(this, hostRef);
125
+ this.results = createEvent(this, "results", 7);
126
+ this.cleared = createEvent(this, "cleared", 7);
127
+ this.componentRendered = createEvent(this, "componentRendered", 7);
128
+ this.shortInput = createEvent(this, "shortInput", 7);
129
+ this.changed = createEvent(this, "changed", 7);
130
+ /**
131
+ * Placeholder for the input field.
132
+ */
133
+ this.placeholder = '';
134
+ /**
135
+ * Id for the input field.
136
+ */
137
+ this.idAttribute = '';
138
+ /**
139
+ * Data attributes for the input field.
140
+ */
141
+ this.dataAttributes = {};
142
+ /**
143
+ * If searching should include MapsIndoors locations.
144
+ */
145
+ this.mapsindoors = false;
146
+ /**
147
+ * If searching should include Google Places autocomplete suggestions.
148
+ *
149
+ * Remember to comply to Google's policy by showing a "Power By Google" badge somewhere on your
150
+ * page if not already showing a Google map: https://developers.google.com/places/web-service/policies
151
+ */
152
+ this.google = false;
153
+ /**
154
+ * If searching should include Mapbox autocomplete suggestions.
155
+ */
156
+ this.mapbox = false;
157
+ /**
158
+ * The language used when retrieving Google Places or Mapbox autocomplete suggestions.
159
+ */
160
+ this.language = 'en';
161
+ /**
162
+ * Which fields on MapsIndoors locations to search in. Comma separated string.
163
+ */
164
+ this.miFields = 'name,description,aliases,categories,externalId';
165
+ /**
166
+ * Make the search field disabled
167
+ */
168
+ this.disabled = false;
169
+ /**
170
+ * Sets the prevention of the search.
171
+ */
172
+ this.preventSearch = false;
145
173
  }
146
- }
147
- /**
148
- * Clear the input field.
149
- */
150
- async clear() {
151
- this.inputElement.value = '';
152
- this.value = '';
153
- this.lastRequested = null;
154
- this.cleared.emit();
155
- }
156
- /**
157
- * Programmatically trigger the search.
158
- */
159
- triggerSearch() {
160
- const inputValue = this.inputElement.value;
161
- this.search(inputValue);
162
- }
163
- /**
164
- * Sets text to be shown in the search field.
165
- * Setting it will not perform a search.
166
- */
167
- setDisplayText(displayText) {
168
- this.preventSearch = true;
169
- this.inputElement.value = displayText;
170
- this.value = displayText;
171
- this.preventSearch = false;
172
- }
173
- /**
174
- * Set focus on the input field.
175
- * The preventScroll boolean is passed as true to prevent the browser
176
- * from scrolling the document to bring the newly-focused element into view.
177
- */
178
- focusInput() {
179
- this.inputElement.focus({ preventScroll: true });
180
- }
181
- /**
182
- * Get hold of the search input field.
183
- */
184
- async getInputField() {
185
- return this.inputElement;
186
- }
187
- /**
188
- * Perform the search.
189
- */
190
- search(inputValue) {
191
- Promise.all([
192
- this.makeMapsIndoorsQuery(inputValue),
193
- this.makeGooglePlacesQuery(inputValue),
194
- this.getMapboxSearchResults(inputValue),
195
- ])
196
- .then(results => {
197
- this.lastRequested = inputValue;
198
- if (this.google) {
199
- this.pushResults(results[0].concat(results[1]));
200
- }
201
- else if (this.mapbox && mapboxgl.accessToken) {
202
- this.pushResults(results[0].concat(results[2]));
203
- }
204
- else {
205
- this.pushResults(results[0]);
206
- }
207
- });
208
- }
209
- /**
210
- * Handles incoming input change event, eg. input field value has changed.
211
- * The function is debounced 500ms to avoid firing too many requests while typing.
212
- */
213
- inputChanged() {
214
- const inputValue = this.inputElement.value;
215
- this.value = inputValue; // reflect on value attribute
216
- if (!this.preventSearch) {
217
- if (inputValue.length < 2) {
218
- this.lastRequested = null;
219
- if (inputValue.length === 1) {
220
- this.shortInput.emit();
174
+ valueChange(newValue) {
175
+ if (!newValue || !this.inputElement) {
176
+ return;
221
177
  }
222
- else {
223
- this.clear();
178
+ if (newValue !== this.inputElement.value) {
179
+ // If newValue is different from what is in the input element, we know it's set from outside the component.
180
+ this.inputElement.value = newValue;
181
+ if (!this.preventSearch) {
182
+ this.inputChanged();
183
+ }
224
184
  }
225
- return;
226
- }
227
- if (inputValue.length > 1 && inputValue !== this.lastRequested) {
185
+ }
186
+ /**
187
+ * Clear the input field.
188
+ */
189
+ async clear() {
190
+ this.inputElement.value = '';
191
+ this.value = '';
192
+ this.lastRequested = null;
193
+ this.cleared.emit();
194
+ }
195
+ /**
196
+ * Programmatically trigger the search.
197
+ */
198
+ async triggerSearch() {
199
+ const inputValue = this.inputElement.value;
228
200
  this.search(inputValue);
229
- }
230
- this.changed.emit();
231
201
  }
232
- }
233
- /**
234
- * Push the results via the results event.
235
- * @param object[] Locations
236
- */
237
- pushResults(locations) {
238
- this.results.emit(locations);
239
- }
240
- /**
241
- * Make MapsIndoors locations request based on given search query.
242
- * @param {string} query
243
- * @return {Promise<any[]>}
244
- */
245
- makeMapsIndoorsQuery(query) {
246
- if (!this.mapsindoors) {
247
- return Promise.resolve([]);
202
+ /**
203
+ * Sets text to be shown in the search field.
204
+ * Setting it will not perform a search.
205
+ */
206
+ async setDisplayText(displayText) {
207
+ this.preventSearch = true;
208
+ this.inputElement.value = displayText;
209
+ this.value = displayText;
210
+ this.preventSearch = false;
211
+ }
212
+ /**
213
+ * Set focus on the input field.
214
+ * The preventScroll boolean is passed as true to prevent the browser
215
+ * from scrolling the document to bring the newly-focused element into view.
216
+ */
217
+ async focusInput() {
218
+ this.inputElement.focus({ preventScroll: true });
219
+ }
220
+ /**
221
+ * Get hold of the search input field.
222
+ */
223
+ async getInputField() {
224
+ return this.inputElement;
248
225
  }
249
- // Transform miNear string attribute to object if it matches a latlng
250
- let miNear;
251
- if (this.miNear) {
252
- miNear = this.miNear;
253
- if (/^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/.test(this.miNear)) {
254
- const near = this.miNear.split(',');
255
- miNear = { lat: parseFloat(near[0]), lng: parseFloat(near[1]) };
256
- }
226
+ /**
227
+ * Perform the search.
228
+ */
229
+ search(inputValue) {
230
+ Promise.all([
231
+ this.makeMapsIndoorsQuery(inputValue),
232
+ this.makeGooglePlacesQuery(inputValue),
233
+ this.getMapboxSearchResults(inputValue),
234
+ ])
235
+ .then(results => {
236
+ this.lastRequested = inputValue;
237
+ if (this.google) {
238
+ this.pushResults(results[0].concat(results[1]));
239
+ }
240
+ else if (this.mapbox && mapboxgl.accessToken) {
241
+ this.pushResults(results[0].concat(results[2]));
242
+ }
243
+ else {
244
+ this.pushResults(results[0]);
245
+ }
246
+ });
257
247
  }
258
- return mapsindoors.services.LocationsService.getLocations({
259
- q: query.trim(),
260
- fields: this.miFields,
261
- take: this.miTake,
262
- skip: this.miSkip,
263
- orderBy: this.miOrder,
264
- near: miNear,
265
- venue: this.miVenue,
266
- categories: this.miCategories
267
- });
268
- }
269
- /**
270
- * Make Google Places autocomplete suggestion request.
271
- *
272
- * @param {string} query
273
- * @return {Promise<any>}
274
- */
275
- makeGooglePlacesQuery(query) {
276
- if (this.google) {
277
- if (!this.googleAutocompleteService) {
278
- this.googleAutocompleteService = new google.maps.places.AutocompleteService();
279
- }
248
+ /**
249
+ * Handles incoming input change event, eg. input field value has changed.
250
+ * The function is debounced 500ms to avoid firing too many requests while typing.
251
+ */
252
+ inputChanged() {
253
+ const inputValue = this.inputElement.value;
254
+ this.value = inputValue; // reflect on value attribute
255
+ if (!this.preventSearch) {
256
+ if (inputValue.length < 2) {
257
+ this.lastRequested = null;
258
+ if (inputValue.length === 1) {
259
+ this.shortInput.emit();
260
+ }
261
+ else {
262
+ this.clear();
263
+ }
264
+ return;
265
+ }
266
+ if (inputValue.length > 1 && inputValue !== this.lastRequested) {
267
+ this.search(inputValue);
268
+ }
269
+ this.changed.emit();
270
+ }
280
271
  }
281
- else {
282
- this.googleAutocompleteService = null;
272
+ /**
273
+ * Push the results via the results event.
274
+ * @param object[] Locations
275
+ */
276
+ pushResults(locations) {
277
+ this.results.emit(locations);
283
278
  }
284
- if (!this.googleAutocompleteService) {
285
- return Promise.resolve([]);
279
+ /**
280
+ * Make MapsIndoors locations request based on given search query.
281
+ * @param {string} query
282
+ * @return {Promise<any[]>}
283
+ */
284
+ makeMapsIndoorsQuery(query) {
285
+ if (!this.mapsindoors) {
286
+ return Promise.resolve([]);
287
+ }
288
+ // Transform miNear string attribute to object if it matches a latlng
289
+ let miNear;
290
+ if (this.miNear) {
291
+ miNear = this.miNear;
292
+ if (/^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/.test(this.miNear)) {
293
+ const near = this.miNear.split(',');
294
+ miNear = { lat: parseFloat(near[0]), lng: parseFloat(near[1]) };
295
+ }
296
+ }
297
+ return mapsindoors.services.LocationsService.getLocations({
298
+ q: query.trim(),
299
+ fields: this.miFields,
300
+ take: this.miTake,
301
+ skip: this.miSkip,
302
+ orderBy: this.miOrder,
303
+ near: miNear,
304
+ venue: this.miVenue,
305
+ categories: this.miCategories
306
+ });
286
307
  }
287
- return new Promise((resolve) => {
288
- const params = {
289
- input: query,
290
- language: this.language
291
- };
292
- if (this.gmCountryCode) {
293
- params.componentRestrictions = { country: this.gmCountryCode };
294
- }
295
- this.googleAutocompleteService.getPlacePredictions(params, (results) => {
296
- const places = (results || []).map((result) => ({
297
- id: result.place_id,
298
- type: 'Feature',
299
- properties: {
300
- type: 'google_places',
301
- placeId: result.place_id,
302
- name: result.structured_formatting.main_text,
303
- subtitle: result.structured_formatting.secondary_text || '',
304
- floor: 0
305
- }
306
- }));
307
- resolve(places);
308
- });
309
- });
310
- }
311
- /**
312
- * Get Mapbox Places results.
313
- *
314
- * @param {string} query
315
- * @return {Promise<any>}
316
- */
317
- getMapboxSearchResults(query) {
318
- if (this.mapbox && mapboxgl.accessToken) {
319
- if (query) {
308
+ /**
309
+ * Make Google Places autocomplete suggestion request.
310
+ *
311
+ * @param {string} query
312
+ * @return {Promise<any>}
313
+ */
314
+ makeGooglePlacesQuery(query) {
315
+ if (this.google) {
316
+ if (!this.googleAutocompleteService) {
317
+ this.googleAutocompleteService = new google.maps.places.AutocompleteService();
318
+ }
319
+ }
320
+ else {
321
+ this.googleAutocompleteService = null;
322
+ }
323
+ if (!this.googleAutocompleteService) {
324
+ return Promise.resolve([]);
325
+ }
320
326
  return new Promise((resolve) => {
321
- const language = this.language.split('-')[0]; // Mapbox seemingly only supports the primary language subtag.
322
- let url = `https://api.mapbox.com/search/searchbox/v1/suggest?q=${query}&session_token=${this.sessionToken}&access_token=${mapboxgl.accessToken}&language=${language}`;
323
- if (this.userPosition) {
324
- url = url.concat(`&proximity=${this.userPosition}`);
325
- }
326
- fetch(url)
327
- .then((response) => {
328
- return response.json();
329
- })
330
- .then((result) => {
331
- const places = result.suggestions.map((result) => ({
332
- id: result.mapbox_id,
333
- type: 'Feature',
334
- properties: {
335
- type: 'mapbox_places',
336
- placeId: result.mapbox_id,
337
- name: result.name,
338
- subtitle: result.place_formatted || '',
339
- floor: 0
340
- }
341
- }));
342
- resolve(places);
343
- })
344
- .catch(() => {
345
- resolve([]);
346
- });
327
+ const params = {
328
+ input: query,
329
+ language: this.language
330
+ };
331
+ if (this.gmCountryCode) {
332
+ params.componentRestrictions = { country: this.gmCountryCode };
333
+ }
334
+ this.googleAutocompleteService.getPlacePredictions(params, (results) => {
335
+ const places = (results || []).map((result) => ({
336
+ id: result.place_id,
337
+ type: 'Feature',
338
+ properties: {
339
+ type: 'google_places',
340
+ placeId: result.place_id,
341
+ name: result.structured_formatting.main_text,
342
+ subtitle: result.structured_formatting.secondary_text || '',
343
+ floor: 0
344
+ }
345
+ }));
346
+ resolve(places);
347
+ });
347
348
  });
348
- }
349
349
  }
350
- else {
351
- return Promise.resolve([]);
350
+ /**
351
+ * Get Mapbox Places results.
352
+ *
353
+ * @param {string} query
354
+ * @return {Promise<any>}
355
+ */
356
+ getMapboxSearchResults(query) {
357
+ if (this.mapbox && mapboxgl.accessToken) {
358
+ if (query) {
359
+ return new Promise((resolve) => {
360
+ const language = this.language.split('-')[0]; // Mapbox seemingly only supports the primary language subtag.
361
+ let url = `https://api.mapbox.com/search/searchbox/v1/suggest?q=${query}&session_token=${this.sessionToken}&access_token=${mapboxgl.accessToken}&language=${language}`;
362
+ if (this.userPosition) {
363
+ url = url.concat(`&proximity=${this.userPosition}`);
364
+ }
365
+ fetch(url)
366
+ .then((response) => {
367
+ return response.json();
368
+ })
369
+ .then((result) => {
370
+ const places = result.suggestions.map((result) => ({
371
+ id: result.mapbox_id,
372
+ type: 'Feature',
373
+ properties: {
374
+ type: 'mapbox_places',
375
+ placeId: result.mapbox_id,
376
+ name: result.name,
377
+ subtitle: result.place_formatted || '',
378
+ floor: 0
379
+ }
380
+ }));
381
+ resolve(places);
382
+ })
383
+ .catch(() => {
384
+ resolve([]);
385
+ });
386
+ });
387
+ }
388
+ }
389
+ else {
390
+ return Promise.resolve([]);
391
+ }
392
+ }
393
+ componentDidRender() {
394
+ if (this.dataAttributes) {
395
+ for (const key in this.dataAttributes) {
396
+ this.inputElement.setAttribute(key, this.dataAttributes[key]);
397
+ }
398
+ }
399
+ this.componentRendered.emit();
352
400
  }
353
- }
354
- componentDidRender() {
355
- if (this.dataAttributes) {
356
- for (const key in this.dataAttributes) {
357
- this.inputElement.setAttribute(key, this.dataAttributes[key]);
358
- }
401
+ render() {
402
+ var _a;
403
+ return (h(Host, { key: '1d524038db7c50caf9fae15f096e2deb7a00260a' }, h("input", { key: '34dfd499754a26fd9dbec28442a357200bbff512', disabled: this.disabled, id: this.idAttribute ? this.idAttribute : null, type: "search", ref: (el) => this.inputElement = el, onInput: () => this.inputChanged(), placeholder: this.placeholder, autocomplete: "off" }), ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value) &&
404
+ h("button", { key: '0247bf1383ae69d463035bfddca474be239581e8', type: "button", onClick: () => this.clear(), "aria-label": "Clear" }, h("svg", { key: '5836e18679a30a44a22881b49aa0934ff8fff13d', width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: 'c3cf6f24d26c0d9b66f4cb2d93c60aded7b5d947', d: "M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" })))));
359
405
  }
360
- this.componentRendered.emit();
361
- }
362
- render() {
363
- var _a;
364
- return (h(Host, null, h("input", { disabled: this.disabled, id: this.idAttribute ? this.idAttribute : null, type: "search", ref: (el) => this.inputElement = el, onInput: () => this.inputChanged(), placeholder: this.placeholder, autocomplete: "off" }), ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value) &&
365
- h("button", { type: "button", onClick: () => this.clear(), "aria-label": "Clear" }, h("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" })))));
366
- }
367
- static get watchers() { return {
368
- "value": ["valueChange"]
369
- }; }
406
+ static get watchers() { return {
407
+ "value": [{
408
+ "valueChange": 0
409
+ }]
410
+ }; }
370
411
  };
371
412
  __decorate([
372
- Debounce(500)
413
+ Debounce(500)
373
414
  ], Search.prototype, "inputChanged", null);
374
- Search.style = searchCss;
415
+ Search.style = searchCss();
375
416
 
376
417
  export { Search as mi_search };