@metadev/lux 0.16.4 → 0.19.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.
Files changed (102) hide show
  1. package/esm2020/lib/autocomplete/autocomplete.component.mjs +479 -0
  2. package/esm2020/lib/autocomplete-list/autocomplete-list.component.mjs +254 -0
  3. package/esm2020/lib/breadcrumb/breadcrumb.component.mjs +75 -0
  4. package/esm2020/lib/checkbox/checkbox.component.mjs +154 -0
  5. package/{esm2015/lib/datasource.js → esm2020/lib/datasource.mjs} +0 -0
  6. package/esm2020/lib/datetime/datetime.component.mjs +306 -0
  7. package/esm2020/lib/filter/filter.component.mjs +152 -0
  8. package/esm2020/lib/geolocation/geolocation.component.mjs +407 -0
  9. package/{esm2015/lib/geolocation/geolocation.service.js → esm2020/lib/geolocation/geolocation.service.mjs} +7 -11
  10. package/esm2020/lib/geolocation/openlayer-loader.service.mjs +62 -0
  11. package/esm2020/lib/helperFns.mjs +109 -0
  12. package/esm2020/lib/input/input.component.mjs +452 -0
  13. package/{esm2015/lib/input/regexp.service.js → esm2020/lib/input/regexp.service.mjs} +7 -6
  14. package/{esm2015/lib/lang.js → esm2020/lib/lang.mjs} +0 -0
  15. package/esm2020/lib/lux.module.mjs +130 -0
  16. package/{esm2015/lib/map/geopoint.js → esm2020/lib/map/geopoint.mjs} +0 -0
  17. package/esm2020/lib/map/map.component.mjs +265 -0
  18. package/esm2020/lib/modal/modal-backdrop.mjs +26 -0
  19. package/esm2020/lib/modal/modal-config.mjs +14 -0
  20. package/{esm2015/lib/modal/modal-dismiss-reasons.js → esm2020/lib/modal/modal-dismiss-reasons.mjs} +0 -0
  21. package/{esm2015/lib/modal/modal-ref.js → esm2020/lib/modal/modal-ref.mjs} +0 -0
  22. package/esm2020/lib/modal/modal-stack.mjs +179 -0
  23. package/esm2020/lib/modal/modal-window.mjs +119 -0
  24. package/esm2020/lib/modal/modal.service.mjs +26 -0
  25. package/{esm2015/lib/modal/util.js → esm2020/lib/modal/util.mjs} +0 -0
  26. package/esm2020/lib/pagination/pagination.component.mjs +137 -0
  27. package/{esm2015/lib/pagination/pagination.js → esm2020/lib/pagination/pagination.mjs} +0 -0
  28. package/esm2020/lib/radiogroup/radiogroup.component.mjs +130 -0
  29. package/esm2020/lib/select/select.component.mjs +149 -0
  30. package/{esm2015/lib/tooltip/placement.js → esm2020/lib/tooltip/placement.mjs} +0 -0
  31. package/{esm2015/lib/tooltip/tooltip-context.js → esm2020/lib/tooltip/tooltip-context.mjs} +0 -0
  32. package/esm2020/lib/tooltip/tooltip.component.mjs +23 -0
  33. package/esm2020/lib/tooltip/tooltip.directive.mjs +60 -0
  34. package/{esm2015/lib/tooltip/tooltip.service.js → esm2020/lib/tooltip/tooltip.service.mjs} +7 -9
  35. package/{esm2015/lib/tooltip/tooltop-content.js → esm2020/lib/tooltip/tooltop-content.mjs} +0 -0
  36. package/esm2020/lib/voice-recognition/voice-recognition.directive.mjs +73 -0
  37. package/{esm2015/lib/window/window.service.js → esm2020/lib/window/window.service.mjs} +0 -0
  38. package/esm2020/metadev-lux.mjs +5 -0
  39. package/esm2020/public-api.mjs +21 -0
  40. package/fesm2015/metadev-lux.mjs +4345 -0
  41. package/fesm2015/metadev-lux.mjs.map +1 -0
  42. package/fesm2020/metadev-lux.mjs +4343 -0
  43. package/fesm2020/metadev-lux.mjs.map +1 -0
  44. package/lib/autocomplete/autocomplete.component.d.ts +3 -0
  45. package/lib/autocomplete-list/autocomplete-list.component.d.ts +3 -0
  46. package/lib/breadcrumb/breadcrumb.component.d.ts +3 -0
  47. package/lib/checkbox/checkbox.component.d.ts +3 -0
  48. package/lib/datetime/datetime.component.d.ts +4 -0
  49. package/lib/filter/filter.component.d.ts +3 -0
  50. package/lib/geolocation/geolocation.component.d.ts +4 -0
  51. package/lib/geolocation/geolocation.service.d.ts +3 -0
  52. package/lib/geolocation/openlayer-loader.service.d.ts +3 -0
  53. package/lib/helperFns.d.ts +2 -0
  54. package/lib/input/input.component.d.ts +15 -0
  55. package/lib/input/regexp.service.d.ts +3 -0
  56. package/lib/lux.module.d.ts +26 -0
  57. package/lib/map/map.component.d.ts +3 -0
  58. package/lib/modal/modal-backdrop.d.ts +3 -0
  59. package/lib/modal/modal-config.d.ts +3 -0
  60. package/lib/modal/modal-stack.d.ts +3 -0
  61. package/lib/modal/modal-window.d.ts +3 -0
  62. package/lib/modal/modal.service.d.ts +3 -0
  63. package/lib/pagination/pagination.component.d.ts +3 -0
  64. package/lib/radiogroup/radiogroup.component.d.ts +3 -0
  65. package/lib/select/select.component.d.ts +3 -0
  66. package/lib/tooltip/tooltip.component.d.ts +3 -0
  67. package/lib/tooltip/tooltip.directive.d.ts +3 -0
  68. package/lib/tooltip/tooltip.service.d.ts +3 -0
  69. package/lib/voice-recognition/voice-recognition.directive.d.ts +3 -0
  70. package/metadev-lux.d.ts +1 -16
  71. package/package.json +22 -10
  72. package/public-api.d.ts +12 -7
  73. package/bundles/metadev-lux.umd.js +0 -4647
  74. package/bundles/metadev-lux.umd.js.map +0 -1
  75. package/esm2015/lib/autocomplete/autocomplete.component.js +0 -455
  76. package/esm2015/lib/autocomplete-list/autocomplete-list.component.js +0 -230
  77. package/esm2015/lib/breadcrumb/breadcrumb.component.js +0 -77
  78. package/esm2015/lib/checkbox/checkbox.component.js +0 -142
  79. package/esm2015/lib/datetime/datetime.component.js +0 -275
  80. package/esm2015/lib/filter/filter.component.js +0 -140
  81. package/esm2015/lib/geolocation/geolocation.component.js +0 -371
  82. package/esm2015/lib/geolocation/openlayer-loader.service.js +0 -63
  83. package/esm2015/lib/helperFns.js +0 -93
  84. package/esm2015/lib/input/input.component.js +0 -371
  85. package/esm2015/lib/lux.module.js +0 -83
  86. package/esm2015/lib/map/map.component.js +0 -261
  87. package/esm2015/lib/modal/modal-backdrop.js +0 -19
  88. package/esm2015/lib/modal/modal-config.js +0 -12
  89. package/esm2015/lib/modal/modal-stack.js +0 -182
  90. package/esm2015/lib/modal/modal-window.js +0 -92
  91. package/esm2015/lib/modal/modal.service.js +0 -28
  92. package/esm2015/lib/pagination/pagination.component.js +0 -134
  93. package/esm2015/lib/radiogroup/radiogroup.component.js +0 -114
  94. package/esm2015/lib/select/select.component.js +0 -131
  95. package/esm2015/lib/tooltip/tooltip.component.js +0 -19
  96. package/esm2015/lib/tooltip/tooltip.directive.js +0 -52
  97. package/esm2015/lib/voice-recognition/voice-recognition.directive.js +0 -76
  98. package/esm2015/metadev-lux.js +0 -21
  99. package/esm2015/public-api.js +0 -16
  100. package/fesm2015/metadev-lux.js +0 -4025
  101. package/fesm2015/metadev-lux.js.map +0 -1
  102. package/metadev-lux.metadata.json +0 -1
@@ -1,4647 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/router'), require('angular-resize-event'), require('rxjs'), require('rxjs/operators'), require('@angular/common/http')) :
3
- typeof define === 'function' && define.amd ? define('@metadev/lux', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/router', 'angular-resize-event', 'rxjs', 'rxjs/operators', '@angular/common/http'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.metadev = global.metadev || {}, global.metadev.lux = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.router, global["angular-resize-event"], global.rxjs, global.rxjs.operators, global.ng.common.http));
5
- })(this, (function (exports, i1, i0, forms, router, angularResizeEvent, rxjs, operators, i1$1) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
26
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
27
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
28
-
29
- // undefined and null functions
30
- var exists = function (value) { return value !== null && value !== undefined; };
31
- var hasValue = function (value) { return exists(value) && (typeof value === 'string' ? !isEmptyString(value) : true); };
32
- // string functions
33
- var isEmptyString = function (value) { return value.trim() === ''; };
34
- var isValidEmail = function (value) {
35
- var re = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
36
- return re.test(String(value).toLowerCase().trim());
37
- };
38
- // date functions
39
- var isValidDate = function (date) { return exists(date) ? !isNaN(date.getTime()) : false; };
40
- var normalizeDate = function (value) {
41
- if (typeof value === 'string' && value.length > 10) {
42
- return value.substr(0, 10);
43
- }
44
- return value ? value.toString() : null;
45
- };
46
- var addTimezoneOffset = function (date) {
47
- if (!isValidDate(date)) {
48
- return date;
49
- }
50
- else {
51
- return new Date(date.getTime() - date.getTimezoneOffset() * 60000);
52
- }
53
- };
54
- // number functions
55
- var isValidNumber = function (value) { return (hasValue(value) ? !Number.isNaN(Number(value)) : false); };
56
- var numberOfDecimalDigits = function (x) {
57
- if (isValidNumber(x)) {
58
- var xString = String(Number(x));
59
- if (xString === 'Infinity') {
60
- return 0;
61
- }
62
- var indexOfE = xString.indexOf('e');
63
- if (indexOfE >= 0) {
64
- return 0;
65
- }
66
- var indexOfDecimalPoint = xString.indexOf('.');
67
- if (indexOfDecimalPoint < 0) {
68
- return 0;
69
- }
70
- else {
71
- return xString.length - indexOfDecimalPoint - 1;
72
- }
73
- }
74
- return undefined;
75
- };
76
- var numberOfWholeDigits = function (x) {
77
- if (isValidNumber(x)) {
78
- var xString = String(Number(x));
79
- if (xString.indexOf('-') === 0) {
80
- xString = xString.slice(1, xString.length);
81
- }
82
- if (xString === 'Infinity') {
83
- return Infinity;
84
- }
85
- if (xString.indexOf('0') === 0) {
86
- xString = xString.slice(1, xString.length);
87
- }
88
- var indexOfE = xString.indexOf('e');
89
- if (indexOfE >= 0) {
90
- return Number(xString.slice(indexOfE + 1, xString.length)) + 1;
91
- }
92
- var indexOfDecimalPoint = xString.indexOf('.');
93
- if (indexOfDecimalPoint < 0) {
94
- return xString.length;
95
- }
96
- else {
97
- return indexOfDecimalPoint;
98
- }
99
- }
100
- return undefined;
101
- };
102
- var roundToMultipleOf = function (x, modulo) {
103
- var moduloString = String(modulo);
104
- // approximates the result
105
- // prone to inexactitude because of floating point arithmetic
106
- var approximation = Math.round(x / modulo) * modulo;
107
- var approximationString = String(approximation);
108
- // remove useless decimals
109
- var uselessDecimalsInApproximation = numberOfDecimalDigits(approximationString) -
110
- numberOfDecimalDigits(moduloString);
111
- var resultString = approximationString.slice(0, approximationString.length - uselessDecimalsInApproximation);
112
- return Number(resultString);
113
- };
114
- // other functions
115
- var isInitialAndEmpty = function (previousValue, newValue) {
116
- var isPrevArray = Array.isArray(previousValue);
117
- var isNewArray = Array.isArray(newValue);
118
- return !((isPrevArray ? previousValue.length !== 0 : Boolean(previousValue)) ||
119
- (isNewArray ? newValue.length !== 0 : Boolean(newValue)));
120
- };
121
-
122
- var LOST_FOCUS_TIME_WINDOW_MS = 200; // ms
123
- var AutocompleteComponent = /** @class */ (function () {
124
- function AutocompleteComponent(cd) {
125
- this.cd = cd;
126
- this.lostFocusHandled = true;
127
- this.t0 = 0;
128
- this.showSpinner = false;
129
- this.touched = false;
130
- this.completionList = [];
131
- this.showCompletion = false;
132
- this.valueChange = new i0.EventEmitter();
133
- this.dataSourceChange = new i0.EventEmitter();
134
- this.disabled = null;
135
- this.readonly = null;
136
- this.label = '';
137
- /** If canAddNewValues, user can type items not present in the data-source. */
138
- this.canAddNewValues = false;
139
- /** After cleaning the selection should the completion list remain open or closed:
140
- * false: (default) close on filters, to clean a filter and select all.
141
- * true: keep open (when the action most likely is to pick another one).
142
- */
143
- this.keepOpenAfterDelete = false;
144
- this.required = false;
145
- this.resolveLabelsFunction = undefined;
146
- this.populateFunction = undefined;
147
- // ControlValueAccessor Interface
148
- this.onChange = function (value) { };
149
- this.onTouched = function () { };
150
- }
151
- Object.defineProperty(AutocompleteComponent.prototype, "value", {
152
- get: function () {
153
- return this._value;
154
- },
155
- set: function (v) {
156
- var initialAndEmpty = isInitialAndEmpty(this._value, v);
157
- this._value = v;
158
- this.onChange(v);
159
- this.completeLabel();
160
- if (!initialAndEmpty) {
161
- this.valueChange.emit(v);
162
- }
163
- },
164
- enumerable: false,
165
- configurable: true
166
- });
167
- Object.defineProperty(AutocompleteComponent.prototype, "dataSource", {
168
- get: function () {
169
- return this._dataSource;
170
- },
171
- set: function (v) {
172
- this._dataSource = v;
173
- this.dataSourceChange.emit(v);
174
- },
175
- enumerable: false,
176
- configurable: true
177
- });
178
- Object.defineProperty(AutocompleteComponent.prototype, "placeholder", {
179
- get: function () {
180
- return this._placeholder ? this._placeholder : '';
181
- },
182
- set: function (v) {
183
- this._placeholder = v;
184
- },
185
- enumerable: false,
186
- configurable: true
187
- });
188
- AutocompleteComponent.prototype.writeValue = function (value) {
189
- this.value = value;
190
- };
191
- AutocompleteComponent.prototype.registerOnChange = function (onChange) {
192
- this.onChange = onChange;
193
- };
194
- AutocompleteComponent.prototype.registerOnTouched = function (onTouched) {
195
- this.onTouched = onTouched;
196
- };
197
- AutocompleteComponent.prototype.markAsTouched = function () {
198
- if (!this.touched && !this.disabled) {
199
- this.onTouched();
200
- this.touched = true;
201
- }
202
- };
203
- AutocompleteComponent.prototype.setDisabledState = function (disabled) {
204
- this.disabled = disabled;
205
- };
206
- // End ControlValueAccessor Interface
207
- // Validator interface
208
- AutocompleteComponent.prototype.registerOnValidatorChange = function () { };
209
- AutocompleteComponent.prototype.validate = function (control) {
210
- var value = control.value;
211
- if (this.required &&
212
- (value === '' || value === null || value === undefined)) {
213
- return { required: { value: value, reason: 'Required field.' } };
214
- }
215
- return null;
216
- };
217
- // End of Validator interface
218
- AutocompleteComponent.prototype.clear = function () {
219
- this.value = null;
220
- this.toggleCompletion(this.keepOpenAfterDelete, '');
221
- };
222
- AutocompleteComponent.prototype.completeLabel = function () {
223
- var _this = this;
224
- if (this.value) {
225
- if (this.dataSource) {
226
- this.label = findLabelForId(this.dataSource, this.value) || '';
227
- }
228
- else if (this.instance && this.resolveLabelsFunction) {
229
- this.resolveLabelsFunction(this.instance, [this.value])
230
- .pipe(operators.debounceTime(1), operators.first())
231
- .subscribe(function (data) {
232
- _this.label = findLabelForId(data, _this.value) || '';
233
- });
234
- }
235
- }
236
- else {
237
- this.label = '';
238
- }
239
- };
240
- AutocompleteComponent.prototype.ngOnInit = function () {
241
- this.inputId = this.inputId
242
- ? this.inputId
243
- : "autocompletelist" + AutocompleteComponent.idCounter++;
244
- this.completeLabel();
245
- };
246
- AutocompleteComponent.prototype.ngAfterViewInit = function () {
247
- this.setSameWidth();
248
- };
249
- AutocompleteComponent.prototype.onInputResized = function () {
250
- this.setSameWidth();
251
- };
252
- AutocompleteComponent.prototype.setSameWidth = function () {
253
- var width = this.i0.nativeElement.getBoundingClientRect().width;
254
- this.completeDiv.nativeElement.style.width = width + "px";
255
- };
256
- AutocompleteComponent.prototype.onKeydown = function (event, label) {
257
- switch (event.key) {
258
- case 'Tab':
259
- if (label) {
260
- this.pickSelectionOrFirstMatch(label);
261
- }
262
- this.showCompletion = false;
263
- break;
264
- }
265
- this.markAsTouched();
266
- };
267
- AutocompleteComponent.prototype.onKeypress = function (event, label) {
268
- switch (event.key) {
269
- case 'Intro':
270
- case 'Enter':
271
- this.pickSelectionOrFirstMatch(label);
272
- event.preventDefault();
273
- break;
274
- }
275
- this.markAsTouched();
276
- };
277
- AutocompleteComponent.prototype.onKeyup = function (event, label) {
278
- switch (event.key) {
279
- case 'PageDown':
280
- this.focusOnNext(5);
281
- event.preventDefault();
282
- break;
283
- case 'ArrowDown':
284
- this.focusOnNext(1);
285
- event.preventDefault();
286
- break;
287
- case 'PageUp':
288
- this.focusOnPrevious(5);
289
- event.preventDefault();
290
- break;
291
- case 'ArrowUp':
292
- this.focusOnPrevious(1);
293
- event.preventDefault();
294
- break;
295
- case 'Escape':
296
- this.complete(null);
297
- event.preventDefault();
298
- break;
299
- case 'Intro':
300
- case 'Enter':
301
- event.preventDefault();
302
- break;
303
- default:
304
- this.showCompletionList(label);
305
- // event.preventDefault();
306
- }
307
- this.markAsTouched();
308
- };
309
- AutocompleteComponent.prototype.focusOnNext = function (offset) {
310
- var _this = this;
311
- var list = this.completionList || [];
312
- var index = list.findIndex(function (it) { return _this.focusItem && it.key === _this.focusItem.key; });
313
- var indexNext = -1 && list.length > index + offset ? index + offset : list.length - 1;
314
- var next = list[indexNext];
315
- this.focusItem = next;
316
- this.ensureItemVisible(index);
317
- };
318
- AutocompleteComponent.prototype.focusOnPrevious = function (offset) {
319
- var _this = this;
320
- var list = this.completionList || [];
321
- var index = list.findIndex(function (it) { return _this.focusItem && it.key === _this.focusItem.key; });
322
- var indexPrevious = index !== -1 && index > offset ? index - offset : 0;
323
- var next = list[indexPrevious];
324
- this.focusItem = next;
325
- this.ensureItemVisible(index);
326
- };
327
- AutocompleteComponent.prototype.onLostFocus = function (label) {
328
- var _this = this;
329
- this.lostFocusHandled = false;
330
- this.t0 = performance.now();
331
- // console.log('Init LostFocus');
332
- setTimeout(function () {
333
- // needs to postpone actions some milliseconds to verify if
334
- // lost focus was followed by a list selection -> then cancel
335
- // if not -> make side effect
336
- if (!_this.lostFocusHandled) {
337
- // console.log(
338
- // 'Lost focus 2',
339
- // this.lostFocusHandled,
340
- // 'SIDE EFFECT',
341
- // performance.now() - this.t0,
342
- // 'label:',
343
- // label
344
- // );
345
- if (label && _this.label !== label) {
346
- _this.pickSelectionOrFirstMatch(label);
347
- }
348
- else {
349
- _this.lostFocusHandled = true;
350
- }
351
- _this.toggleCompletion(false, label);
352
- }
353
- else {
354
- // do nothing (list selection took place)
355
- // console.log(
356
- // 'onlost focus 2',
357
- // this.lostFocusHandled,
358
- // 'nothing',
359
- // performance.now() - this.t0
360
- // );
361
- }
362
- }, LOST_FOCUS_TIME_WINDOW_MS);
363
- };
364
- AutocompleteComponent.prototype.complete = function (item) {
365
- if (!this.lostFocusHandled) {
366
- this.lostFocusHandled = true; // prevent a previous lostFocus to trigger a side effect
367
- var ellapsed = performance.now() - this.t0;
368
- if (ellapsed > LOST_FOCUS_TIME_WINDOW_MS) {
369
- console.warn('complete. lostfocus->click timeout of ', LOST_FOCUS_TIME_WINDOW_MS, 'ms exceed: ', performance.now() - this.t0, ' ms');
370
- }
371
- // console.log(
372
- // 'complete. set to true. CANCELED side effect',
373
- // performance.now() - this.t0
374
- // );
375
- }
376
- if (item !== null) {
377
- this.value = item.key;
378
- this.label = item.label;
379
- }
380
- else {
381
- this.value = null;
382
- this.label = '';
383
- }
384
- this.toggleCompletion(false, null);
385
- this.markAsTouched();
386
- };
387
- AutocompleteComponent.prototype.toggleCompletion = function (show, label) {
388
- if (show && !this.disabled) {
389
- this.showCompletionList(label);
390
- }
391
- else {
392
- this.showCompletion = false;
393
- if (this.canAddNewValues) {
394
- this.syncCustomValue(this.label);
395
- return;
396
- }
397
- }
398
- this.cd.markForCheck();
399
- };
400
- Object.defineProperty(AutocompleteComponent.prototype, "selectedOption", {
401
- get: function () {
402
- var _this = this;
403
- var index = this.completionList.findIndex(function (i) { return i.key === _this.focusItem.key; });
404
- if (index === -1 || !this.focusItem) {
405
- return null;
406
- }
407
- return this.inputId + "_" + index;
408
- },
409
- enumerable: false,
410
- configurable: true
411
- });
412
- AutocompleteComponent.prototype.ensureItemVisible = function (index) {
413
- var target = this.completeDiv.nativeElement.querySelectorAll('li')[index];
414
- if (target) {
415
- target.scrollIntoView({ block: 'center' });
416
- }
417
- };
418
- AutocompleteComponent.prototype.syncCustomValue = function (text) {
419
- this.value = text;
420
- this.label = text;
421
- };
422
- /** Pick selection based on text filtering (ingnores drowdown state) */
423
- AutocompleteComponent.prototype.pickSelectionOrFirstMatch = function (text) {
424
- var _this = this;
425
- if (this.canAddNewValues) {
426
- this.syncCustomValue(text);
427
- return;
428
- }
429
- var focusIndex = this.completionList.findIndex(function (it) { return _this.focusItem && it.key === _this.focusItem.key; });
430
- if (this.showCompletion &&
431
- focusIndex > 0 &&
432
- this.focusItem &&
433
- this.focusItem.label) {
434
- if (text === this.focusItem.label && this.focusItem.key === this.value) {
435
- // do nothing if value does not change & close dropdow
436
- this.showCompletion = false;
437
- return;
438
- }
439
- // complete selected using selected item on drowdown
440
- this.complete(this.focusItem);
441
- return;
442
- }
443
- var source = (text || '').trim();
444
- if (!source) {
445
- this.showCompletion = false;
446
- // select null value
447
- if (this.value !== null) {
448
- this.value = null;
449
- }
450
- return;
451
- }
452
- this.completionList = [];
453
- this.computeCompletionList(source).subscribe(function (suggestions) {
454
- var candidate = suggestions && suggestions.length > 0 ? suggestions[0] : null;
455
- _this.complete(candidate);
456
- });
457
- };
458
- AutocompleteComponent.prototype.showCompletionList = function (text) {
459
- var _this = this;
460
- this.setSameWidth();
461
- var useSpinner = this.hasExternalDataSource();
462
- this.spinnerVisibility(useSpinner, true);
463
- setTimeout(function () {
464
- // for spinner to be shown
465
- _this.computeCompletionList(text).subscribe({
466
- next: function (cl) {
467
- _this.completionList = cl;
468
- _this.focusItem = selectElement(_this.completionList, text);
469
- _this.showCompletion = true;
470
- _this.spinnerVisibility(useSpinner, false);
471
- },
472
- error: function () {
473
- _this.spinnerVisibility(useSpinner, false);
474
- },
475
- complete: function () {
476
- _this.spinnerVisibility(useSpinner, false);
477
- }
478
- });
479
- }, 1);
480
- };
481
- AutocompleteComponent.prototype.spinnerVisibility = function (useSpinner, value) {
482
- if (useSpinner) {
483
- this.showSpinner = value;
484
- }
485
- };
486
- AutocompleteComponent.prototype.hasExternalDataSource = function () {
487
- return !this.dataSource && !!this.instance && !!this.populateFunction;
488
- };
489
- AutocompleteComponent.prototype.computeCompletionList = function (text) {
490
- var searchText = (text || '').toLowerCase();
491
- if (this.dataSource) {
492
- var ds = (this.dataSource || [])
493
- .filter(function (it) { return ignoreAccentsInclude(it.label, searchText); })
494
- .sort(function (a, b) { return a.label.localeCompare(b.label); });
495
- return rxjs.of(decorateDataSource(ds, searchText));
496
- }
497
- else if (this.instance && this.populateFunction) {
498
- return this.populateFunction(this.instance, searchText).pipe(operators.debounceTime(1), operators.first(), operators.map(function (ds) {
499
- var dsFiltered = ds
500
- .filter(function (it) { return ignoreAccentsInclude(it.label, searchText); })
501
- .sort(function (a, b) { return a.label.localeCompare(b.label); });
502
- return decorateDataSource(dsFiltered, searchText);
503
- }));
504
- }
505
- else {
506
- return rxjs.of([]);
507
- }
508
- };
509
- return AutocompleteComponent;
510
- }());
511
- AutocompleteComponent.idCounter = 0;
512
- AutocompleteComponent.decorators = [
513
- { type: i0.Component, args: [{
514
- selector: 'lux-autocomplete',
515
- template: "<div class=\"lux-autocomplete\" (blur)=\"toggleCompletion(false, i0.value)\">\n <div class=\"lux-autocomplete-box\">\n <input\n #i0\n [id]=\"inputId\"\n [(ngModel)]=\"label\"\n [placeholder]=\"placeholder\"\n [attr.disabled]=\"disabled || null\"\n [attr.readonly]=\"readonly || null\"\n (keydown)=\"onKeydown($event, i0.value)\"\n (keypress)=\"onKeypress($event, i0.value)\"\n (keyup)=\"onKeyup($event, i0.value)\"\n (blur)=\"onLostFocus(i0.value)\"\n (focus)=\"toggleCompletion(true, i0.value)\"\n (click)=\"toggleCompletion(true, i0.value)\"\n (resized)=\"onInputResized()\"\n (window:resize)=\"onInputResized()\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n [attr.aria-expanded]=\"showCompletion\"\n aria-haspopup=\"true\"\n attr.aria-owns=\"{{ inputId + '_list' }}\"\n [attr.aria-activedescendant]=\"selectedOption\"\n />\n <div *ngIf=\"canAddNewValues\" class=\"icon-suggestions\"></div>\n <div *ngIf=\"showSpinner; else noLoading\" class=\"icon-spinner\"></div>\n <ng-template #noLoading>\n <button\n *ngIf=\"!disabled && i0.value && !showCompletion; else dropdown\"\n type=\"button\"\n class=\"icon-clear\"\n aria-label=\"Clear\"\n (click)=\"clear()\"\n ></button>\n <ng-template #dropdown>\n <div\n class=\"icon-dropdown\"\n (click)=\"toggleCompletion(!showCompletion, i0.value)\"\n ></div>\n </ng-template>\n </ng-template>\n </div>\n <div\n #completeDiv\n [class.showCompletion]=\"showCompletion\"\n class=\"lux-completion-list\"\n id=\"{{ inputId + '_list' }}\"\n >\n <ul>\n <li\n *ngFor=\"let item of completionList; let index = index\"\n id=\"{{ inputId + '_' + index }}\"\n class=\"lux-completion-item\"\n [class.selected]=\"focusItem && item.key === focusItem.key\"\n (click)=\"complete(item)\"\n [attr.aria-label]=\"item.label\"\n >\n <span>{{ item.labelPrefix }}</span>\n <span class=\"bold\">{{ item.labelMatch }}</span>\n <span>{{ item.labelPostfix }}</span>\n </li>\n </ul>\n </div>\n</div>\n",
516
- providers: [
517
- {
518
- provide: forms.NG_VALUE_ACCESSOR,
519
- multi: true,
520
- useExisting: i0.forwardRef(function () { return AutocompleteComponent; })
521
- },
522
- {
523
- provide: forms.NG_VALIDATORS,
524
- multi: true,
525
- useExisting: i0.forwardRef(function () { return AutocompleteComponent; })
526
- }
527
- ],
528
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}.lux-autocomplete .lux-autocomplete-box{display:grid;grid-template-columns:1fr -webkit-max-content;grid-template-columns:1fr max-content}.lux-autocomplete input{padding:.1rem 1.5rem .1rem .5rem;padding:var(--lux-autocomplete-input-padding, .1rem 1.5rem .1rem .5rem);text-overflow:ellipsis;grid-row:1;grid-column-start:1;grid-column-end:3}.lux-autocomplete .icon-suggestions{grid-row:1;grid-column:2;width:1.5rem;border:none;background-color:transparent;background:url(/assets/img/suggestions.svg) no-repeat center;background-size:.5rem .5rem;z-index:1;position:relative;left:-1rem}.lux-autocomplete .icon-clear{grid-row:1;grid-column:2;width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);border:none;background-color:transparent;background:url(/assets/img/filter-clear.png) no-repeat center;background:var(--lux-autocomplete-icon-clear, url(/assets/img/filter-clear.png) no-repeat center);background-size:.5rem .5rem;background-size:var(--lux-autocomplete-icon-bg-size, .5rem .5rem);z-index:1}.lux-autocomplete .icon-dropdown{grid-row:1;grid-column:2;width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);height:1.3rem;height:var(--lux-autocomplete-icon-height, 1.3rem);border:none;background-color:transparent;background:url(/assets/img/drop-down-arrow.svg) no-repeat center;background:var(--lux-autocomplete-icon-dropdown, url(/assets/img/drop-down-arrow.svg) no-repeat center);background-size:.5rem .5rem;background-size:var(--lux-autocomplete-icon-bg-size, .5rem .5rem);z-index:1}.lux-autocomplete .icon-spinner{grid-row:1;grid-column:2;width:1.5rem;border:none;background-color:transparent;background:url(/assets/img/spinner.svg) no-repeat center;background-size:1.2rem 1.2rem;z-index:1}.lux-completion-list{visibility:collapse;position:absolute;border:1px solid #ccc;margin:0;padding:0;max-height:10rem;overflow:auto;z-index:2}.lux-completion-list ul{list-style:none;margin:0;padding:0}.showCompletion{visibility:visible}.lux-completion-item{background-color:#fff;color:#000;padding:.1rem .5rem;cursor:pointer}.selected{background-color:#2e2eac;color:#fff}.disabled{background-color:#f0f0f0;color:#444}.disabled .selected{background-color:#9898ec;color:#fff}.bold{font-weight:bold}\n"]
529
- },] }
530
- ];
531
- AutocompleteComponent.ctorParameters = function () { return [
532
- { type: i0.ChangeDetectorRef }
533
- ]; };
534
- AutocompleteComponent.propDecorators = {
535
- i0: [{ type: i0.ViewChild, args: ['i0', { static: true },] }],
536
- completeDiv: [{ type: i0.ViewChild, args: ['completeDiv', { static: true },] }],
537
- valueChange: [{ type: i0.Output }],
538
- dataSourceChange: [{ type: i0.Output }],
539
- inputId: [{ type: i0.Input }],
540
- disabled: [{ type: i0.Input }],
541
- readonly: [{ type: i0.Input }],
542
- label: [{ type: i0.Input }],
543
- canAddNewValues: [{ type: i0.Input }],
544
- keepOpenAfterDelete: [{ type: i0.Input }],
545
- value: [{ type: i0.Input }],
546
- dataSource: [{ type: i0.Input }],
547
- required: [{ type: i0.Input }],
548
- placeholder: [{ type: i0.Input }],
549
- resolveLabelsFunction: [{ type: i0.Input }],
550
- populateFunction: [{ type: i0.Input }],
551
- instance: [{ type: i0.Input }]
552
- };
553
- /** Returns true if text includes substring. No accents considered. Ignorecase */
554
- var ignoreAccentsInclude = function (text, substring) {
555
- text = normalizedString(text).toLowerCase();
556
- substring = normalizedString(substring).toLowerCase();
557
- return text.includes(substring);
558
- };
559
- var ɵ0$3 = ignoreAccentsInclude;
560
- /** Returns a normalized string with no accents: used for comparison */
561
- var normalizedString = function (a) { return (a || '').normalize('NFD').replace(/[\u0300-\u036f]/g, ''); };
562
- var ɵ1$2 = normalizedString;
563
- var decorateDataSource = function (dataSource, subString) { return dataSource.map(function (it) { return decorateItem(it, subString); }); };
564
- var ɵ2 = decorateDataSource;
565
- var decorateItem = function (item, tx) {
566
- var index = normalizedString(item.label)
567
- .toLowerCase()
568
- .indexOf(normalizedString(tx).toLowerCase());
569
- var labelPrefix = index === -1 ? item.label : item.label.substr(0, index);
570
- var labelMatch = index === -1 ? '' : item.label.substr(index, tx.length);
571
- var labelPostfix = index === -1 ? '' : item.label.substr(index + tx.length);
572
- var newItem = Object.assign(Object.assign({}, item), { labelPrefix: labelPrefix,
573
- labelMatch: labelMatch,
574
- labelPostfix: labelPostfix });
575
- return newItem;
576
- };
577
- var ɵ3 = decorateItem;
578
- var findLabelForId = function (data, id) {
579
- var found = data.find(function (it) { return it.key === id; });
580
- return found ? found.label : null;
581
- };
582
- var ɵ4 = findLabelForId;
583
- var selectElement = function (completionList, label) {
584
- label = (label || '').toLowerCase();
585
- if (!completionList || completionList.length === 0) {
586
- return null;
587
- }
588
- if (completionList.length === 1) {
589
- return completionList[0];
590
- }
591
- var found = completionList.find(function (it) { return it.label.toLowerCase() === label; });
592
- return found || completionList[0];
593
- };
594
-
595
- /** Language detector based on Navigator preferences */
596
- var languageDetector = function () {
597
- var lang = navigator.language.split('-')[0];
598
- if (lang === 'es' || lang === 'en') {
599
- return lang;
600
- }
601
- return 'en'; // default
602
- };
603
-
604
- var AutocompleteListComponent = /** @class */ (function () {
605
- function AutocompleteListComponent() {
606
- this.literals = {
607
- en: {
608
- placeholder: 'new item',
609
- deleteLabelTemplate: 'Delete <<label>>',
610
- addMessage: 'Add'
611
- },
612
- es: {
613
- placeholder: 'nuevo elemento',
614
- deleteLabelTemplate: 'Eliminar <<label>>',
615
- addMessage: 'Añadir'
616
- }
617
- };
618
- this.internalDataSource = [];
619
- this.autoPopulate = false;
620
- this._value = [];
621
- this.labels = [];
622
- this.canAdd = false;
623
- this.touched = false;
624
- this._lang = languageDetector();
625
- this.dataSource = [];
626
- this.disabled = false;
627
- this.required = false;
628
- this.resolveLabelsFunction = undefined;
629
- this.populateFunction = undefined;
630
- this.valueChange = new i0.EventEmitter();
631
- // ControlValueAccessor Interface
632
- this.onChange = function (value) { };
633
- this.onTouched = function () { };
634
- }
635
- Object.defineProperty(AutocompleteListComponent.prototype, "value", {
636
- get: function () {
637
- return this._value;
638
- },
639
- set: function (val) {
640
- if (val === this._value) {
641
- return;
642
- }
643
- var initialAndEmpty = isInitialAndEmpty(this._value, val);
644
- this._value = val;
645
- this.ensureLabelsForIds();
646
- this.populateWith('');
647
- this.onChange(this._value);
648
- if (!initialAndEmpty) {
649
- this.valueChange.emit(this._value);
650
- }
651
- },
652
- enumerable: false,
653
- configurable: true
654
- });
655
- Object.defineProperty(AutocompleteListComponent.prototype, "lang", {
656
- get: function () {
657
- return this._lang;
658
- },
659
- set: function (l) {
660
- if (l === this._lang) {
661
- return;
662
- }
663
- if (Object.keys(this.literals).includes(l)) {
664
- this._lang = l;
665
- }
666
- else {
667
- this._lang = 'en';
668
- }
669
- },
670
- enumerable: false,
671
- configurable: true
672
- });
673
- AutocompleteListComponent.prototype.writeValue = function (value) {
674
- this.value = value;
675
- };
676
- AutocompleteListComponent.prototype.registerOnChange = function (onChange) {
677
- this.onChange = onChange;
678
- };
679
- AutocompleteListComponent.prototype.registerOnTouched = function (onTouched) {
680
- this.onTouched = onTouched;
681
- };
682
- AutocompleteListComponent.prototype.markAsTouched = function () {
683
- if (!this.touched && !this.disabled) {
684
- this.onTouched();
685
- this.touched = true;
686
- }
687
- };
688
- AutocompleteListComponent.prototype.setDisabledState = function (disabled) {
689
- this.disabled = disabled;
690
- };
691
- // End ControlValueAccessor Interface
692
- // Validator interface
693
- AutocompleteListComponent.prototype.registerOnValidatorChange = function () { };
694
- AutocompleteListComponent.prototype.validate = function (control) {
695
- var value = control.value;
696
- if (this.required &&
697
- (value === '' || value === null || value === undefined)) {
698
- return { required: { value: value, reason: 'Required field.' } };
699
- }
700
- return null;
701
- };
702
- // End of Validator interface
703
- AutocompleteListComponent.prototype.ngOnInit = function () {
704
- this.inputId = this.inputId
705
- ? this.inputId
706
- : "autocompletelist" + AutocompleteListComponent.idCounter++;
707
- this.autoPopulate =
708
- !!this.resolveLabelsFunction && !!this.populateFunction && this.instance;
709
- this.ensureLabelsForIds();
710
- };
711
- AutocompleteListComponent.prototype.ensureLabelsForIds = function () {
712
- var _this = this;
713
- if (this.autoPopulate && this.resolveLabelsFunction) {
714
- this.resolveLabelsFunction(this.instance, this._value)
715
- .pipe(operators.first())
716
- .subscribe(function (data) {
717
- var res = [];
718
- (_this._value || []).map(function (id) {
719
- var found = data.find(function (it) { return it.key === id; });
720
- if (found) {
721
- res.push(found.label);
722
- }
723
- else {
724
- res.push('(unset)');
725
- }
726
- });
727
- _this.labels = res;
728
- });
729
- }
730
- else if (this.dataSource) {
731
- var res_1 = [];
732
- (this._value || []).map(function (id) {
733
- var found = _this.dataSource.find(function (it) { return it.key === id; });
734
- if (found) {
735
- res_1.push(found.label);
736
- }
737
- else {
738
- res_1.push('(unset)');
739
- }
740
- });
741
- this.labels = res_1;
742
- }
743
- else {
744
- this.labels = this._value.map(function (it) { return (it ? it.toString() : '(unset)'); });
745
- }
746
- };
747
- AutocompleteListComponent.prototype.removeAt = function (index) {
748
- if (this._value.length > index) {
749
- var key = this._value.splice(index, 1)[0];
750
- var label = this.labels.splice(index, 1)[0];
751
- this.internalDataSource.push({ key: key, label: label });
752
- }
753
- this.markAsTouched();
754
- };
755
- AutocompleteListComponent.prototype.onValueChange = function () {
756
- this.updateCanAdd();
757
- };
758
- AutocompleteListComponent.prototype.onNewEntryChange = function (event, auto) {
759
- if (event.key === 'Enter' && !!auto.value) {
760
- this.addNew(auto);
761
- }
762
- else if (event.key === 'Delete' || event.key === 'Backspace') {
763
- // todo
764
- }
765
- else {
766
- this.populateWith(auto.label + event.key);
767
- }
768
- this.updateCanAdd();
769
- };
770
- AutocompleteListComponent.prototype.populateWith = function (searchText) {
771
- var _this = this;
772
- if (this.autoPopulate && this.populateFunction && this.instance) {
773
- this.populateFunction(this.instance, searchText)
774
- .pipe(operators.first())
775
- .subscribe(function (data) {
776
- _this.internalDataSource = data.filter(function (it) { return !(_this._value || []).includes(it.key); });
777
- });
778
- }
779
- else if (this.dataSource) {
780
- this.internalDataSource = this.dataSource.filter(function (it) { return !(_this._value || []).includes(it.key); });
781
- }
782
- };
783
- AutocompleteListComponent.prototype.updateCanAdd = function () {
784
- var _this = this;
785
- this.canAdd =
786
- !this.disabled &&
787
- this.auto &&
788
- !!this.auto.value && // has value
789
- !this.value.find(function (it) { return it === _this.auto.value; }); // not already in
790
- };
791
- AutocompleteListComponent.prototype.addNew = function (auto) {
792
- var _this = this;
793
- this.value.push(auto.value);
794
- this.ensureLabelsForIds();
795
- this.newEntry = '';
796
- this.internalDataSource = this.internalDataSource.filter(function (it) { return !_this._value.includes(it.key); });
797
- this.markAsTouched();
798
- };
799
- AutocompleteListComponent.prototype.getDeleteMessage = function (label) {
800
- var _a;
801
- return ((_a = this.deleteLabelTemplate) !== null && _a !== void 0 ? _a : this.literals[this.lang].deleteLabelTemplate).replace('<<label>>', label);
802
- };
803
- return AutocompleteListComponent;
804
- }());
805
- AutocompleteListComponent.idCounter = 0;
806
- AutocompleteListComponent.decorators = [
807
- { type: i0.Component, args: [{
808
- selector: 'lux-autocomplete-list',
809
- template: "<div [id]=\"inputId\">\n <ul>\n <li *ngFor=\"let label of labels; let index = index\">\n <span>{{ label }}</span>\n <button\n *ngIf=\"!disabled\"\n class=\"remove-item\"\n (click)=\"removeAt(index)\"\n attr.aria-label=\"{{ getDeleteMessage(label) }}\"\n ></button>\n </li>\n </ul>\n <div *ngIf=\"!disabled\" class=\"new-entry\">\n <lux-autocomplete\n #auto\n [dataSource]=\"internalDataSource\"\n [placeholder]=\"placeholder ?? literals[lang].placeholder\"\n [(value)]=\"newEntry\"\n (valueChange)=\"onValueChange()\"\n (keypress)=\"onNewEntryChange($event, auto)\"\n >\n </lux-autocomplete>\n <button\n *ngIf=\"canAdd\"\n class=\"add-item\"\n attr.aria-label=\"addMessage ?? literals[lang].addMessage\"\n (click)=\"addNew(auto)\"\n ></button>\n </div>\n</div>\n",
810
- providers: [
811
- {
812
- provide: forms.NG_VALUE_ACCESSOR,
813
- multi: true,
814
- useExisting: i0.forwardRef(function () { return AutocompleteListComponent; })
815
- },
816
- {
817
- provide: forms.NG_VALIDATORS,
818
- multi: true,
819
- useExisting: i0.forwardRef(function () { return AutocompleteListComponent; })
820
- }
821
- ],
822
- styles: [".new-entry{margin-left:1.5rem;display:grid;grid-template-columns:-webkit-max-content -webkit-max-content;grid-template-columns:max-content max-content}.new-entry lux-autocomplete{grid-column:1;grid-row:1}.new-entry .add-item{grid-column:2;grid-row:1;border:none;background:url(/assets/img/create.png) no-repeat .2rem .2rem;background:var(--lux-autocomplete-list-add-icon, url(/assets/img/create.png) no-repeat .2rem .2rem);background-size:1.1rem;background-size:var(--lux-autocomplete-list-add-icon-size, 1.1rem);height:1.4rem;height:var(--lux-autocomplete-list-add-icon-height, 1.4rem);width:1.4rem;width:var(--lux-autocomplete-list-add-icon-width, 1.4rem)}.remove-item{margin-left:.5rem;border:none;background:url(/assets/img/delete.svg) no-repeat .2rem .1rem;background:var(--lux-autocomplete-list-remove-icon, url(/assets/img/delete.svg) no-repeat .2rem .1rem);height:1.2rem;height:var(--lux-autocomplete-list-remove-icon-height, 1.2rem);width:1.3rem;width:var(--lux-autocomplete-list-remove-icon-width, 1.3rem);position:relative;top:.2rem;top:var(--lux-autocomplete-list-remove-icon-top, .2rem);background-size:1rem 1rem;background-size:var(--lux-autocomplete-list-remove-icon-size, 1rem 1rem)}\n"]
823
- },] }
824
- ];
825
- AutocompleteListComponent.propDecorators = {
826
- auto: [{ type: i0.ViewChild, args: ['auto',] }],
827
- value: [{ type: i0.Input }],
828
- lang: [{ type: i0.Input }],
829
- inputId: [{ type: i0.Input }],
830
- dataSource: [{ type: i0.Input }],
831
- placeholder: [{ type: i0.Input }],
832
- disabled: [{ type: i0.Input }],
833
- deleteLabelTemplate: [{ type: i0.Input }],
834
- addMessage: [{ type: i0.Input }],
835
- required: [{ type: i0.Input }],
836
- resolveLabelsFunction: [{ type: i0.Input }],
837
- populateFunction: [{ type: i0.Input }],
838
- instance: [{ type: i0.Input }],
839
- valueChange: [{ type: i0.Output }]
840
- };
841
-
842
- var KEY_SPACE = ' ';
843
- var CheckboxComponent = /** @class */ (function () {
844
- function CheckboxComponent() {
845
- this._lang = languageDetector();
846
- this.label = null;
847
- this.name = null;
848
- this._disabled = false;
849
- this.literals = {
850
- en: {
851
- yesLabel: 'Yes',
852
- noLabel: 'No'
853
- },
854
- es: {
855
- yesLabel: 'Sí',
856
- noLabel: 'No'
857
- }
858
- };
859
- this.touched = false;
860
- this.valueChange = new i0.EventEmitter();
861
- // ControlValueAccessor Interface
862
- this.onChange = function (value) { };
863
- this.onTouched = function () { };
864
- }
865
- Object.defineProperty(CheckboxComponent.prototype, "lang", {
866
- get: function () {
867
- return this._lang;
868
- },
869
- set: function (l) {
870
- if (l === this._lang) {
871
- return;
872
- }
873
- if (Object.keys(this.literals).includes(l)) {
874
- this._lang = l;
875
- }
876
- else {
877
- this._lang = 'en';
878
- }
879
- },
880
- enumerable: false,
881
- configurable: true
882
- });
883
- Object.defineProperty(CheckboxComponent.prototype, "value", {
884
- get: function () {
885
- return this.internalValue;
886
- },
887
- set: function (v) {
888
- if (this.internalValue === v) {
889
- return;
890
- }
891
- var initialAndEmpty = isInitialAndEmpty(this.internalValue, v);
892
- this.internalValue = v;
893
- this.syncModel();
894
- this.onChange(v);
895
- if (!initialAndEmpty) {
896
- this.valueChange.emit(v);
897
- }
898
- },
899
- enumerable: false,
900
- configurable: true
901
- });
902
- Object.defineProperty(CheckboxComponent.prototype, "tabindexValue", {
903
- get: function () {
904
- return this.disabled ? null : '0';
905
- },
906
- enumerable: false,
907
- configurable: true
908
- });
909
- Object.defineProperty(CheckboxComponent.prototype, "disabled", {
910
- get: function () {
911
- return this._disabled;
912
- },
913
- set: function (v) {
914
- if (v === this._disabled) {
915
- return;
916
- }
917
- this._disabled = v;
918
- this.syncModel();
919
- },
920
- enumerable: false,
921
- configurable: true
922
- });
923
- CheckboxComponent.prototype.writeValue = function (value) {
924
- this.value = !!value;
925
- };
926
- CheckboxComponent.prototype.registerOnChange = function (onChange) {
927
- this.onChange = onChange;
928
- };
929
- CheckboxComponent.prototype.registerOnTouched = function (onTouched) {
930
- this.onTouched = onTouched;
931
- };
932
- CheckboxComponent.prototype.markAsTouched = function () {
933
- if (!this.touched) {
934
- this.onTouched();
935
- this.touched = true;
936
- }
937
- };
938
- CheckboxComponent.prototype.setDisabledState = function (disabled) {
939
- this.disabled = disabled;
940
- };
941
- // End ControlValueAccessor Interface
942
- CheckboxComponent.prototype.ngOnInit = function () {
943
- this.inputId = this.inputId
944
- ? this.inputId
945
- : (this.name || 'checkbox') + "$" + CheckboxComponent.idCounter++;
946
- };
947
- CheckboxComponent.prototype.ngAfterViewInit = function () {
948
- this.syncModel();
949
- };
950
- CheckboxComponent.prototype.clicked = function () {
951
- if (!this.disabled) {
952
- this.value = !this.internalValue;
953
- this.markAsTouched();
954
- }
955
- };
956
- CheckboxComponent.prototype.onKey = function (event) {
957
- if (event.key === KEY_SPACE && !this.disabled) {
958
- this.value = !this.internalValue;
959
- this.markAsTouched();
960
- event.preventDefault();
961
- }
962
- };
963
- CheckboxComponent.prototype.syncModel = function () {
964
- if (this.ck) {
965
- this.ck.nativeElement.checked = this.internalValue;
966
- }
967
- };
968
- return CheckboxComponent;
969
- }());
970
- CheckboxComponent.idCounter = 0;
971
- CheckboxComponent.decorators = [
972
- { type: i0.Component, args: [{
973
- selector: 'lux-checkbox',
974
- template: "<div class=\"switch\">\n <div>\n <label *ngIf=\"label\" [for]=\"inputId\">{{ label }}</label>\n </div>\n <div *ngIf=\"!disabled\" class=\"switch-item\" (click)=\"clicked()\">\n <input #ck [name]=\"name\" type=\"checkbox\" [id]=\"inputId\" />\n <div\n class=\"slider round\"\n [class.on]=\"value\"\n [class.disabled]=\"disabled\"\n [tabindex]=\"tabindexValue\"\n (keyup)=\"onKey($event)\"\n ></div>\n </div>\n <div>\n <span class=\"checkbox-label\" *ngIf=\"value\">{{\n literals[lang].yesLabel\n }}</span>\n <span class=\"checkbox-label\" *ngIf=\"!value\">{{\n literals[lang].noLabel\n }}</span>\n </div>\n</div>\n",
975
- providers: [
976
- {
977
- provide: forms.NG_VALUE_ACCESSOR,
978
- multi: true,
979
- useExisting: i0.forwardRef(function () { return CheckboxComponent; })
980
- }
981
- ],
982
- styles: [".switch{display:flex;flex-flow:row wrap;align-items:center}label{padding-right:1.1rem}.switch-item{padding-right:.5em}.slider.round{border-radius:.7rem;width:3.1rem;height:1.4rem}.slider.round:before{border-radius:50%}.switch input{opacity:0;width:0;height:0}.slider{cursor:pointer;position:relative;top:-.7rem;background-color:#ccc;transition:.4s}.slider.on{background-color:#2196f3}.slider:before{position:absolute;content:\"\";height:1rem;width:1rem;left:.2rem;bottom:.2rem;background-color:#fff;transition:.4s}.slider.on:before{transform:translate(26px)}input:focus+.slider{box-shadow:0 0 1px #2196f3}\n"]
983
- },] }
984
- ];
985
- CheckboxComponent.ctorParameters = function () { return []; };
986
- CheckboxComponent.propDecorators = {
987
- ck: [{ type: i0.ViewChild, args: ['ck', { static: false },] }],
988
- lang: [{ type: i0.Input }],
989
- value: [{ type: i0.Input }],
990
- label: [{ type: i0.Input }],
991
- name: [{ type: i0.Input }],
992
- disabled: [{ type: i0.Input }],
993
- inputId: [{ type: i0.Input }],
994
- valueChange: [{ type: i0.Output }]
995
- };
996
-
997
- var DatetimeComponent = /** @class */ (function () {
998
- function DatetimeComponent() {
999
- this.touched = false;
1000
- this.dirty = false;
1001
- this.lastErrors = null;
1002
- this.dateValue = undefined;
1003
- this.timeValue = undefined;
1004
- this.userErrors = {
1005
- en: {
1006
- required: 'Required field.',
1007
- min: 'Minimum value is $min.',
1008
- max: 'Maximum value is $max.'
1009
- },
1010
- es: {
1011
- required: 'El campo es obligatorio.',
1012
- min: 'El valor mínimo es $min.',
1013
- max: 'El valor máximo es $max.'
1014
- }
1015
- };
1016
- this.min = '1900-01-01T00:00:00Z';
1017
- this.max = '2100-01-01T00:00:00Z';
1018
- this.includeSeconds = true;
1019
- this.localTime = true;
1020
- this.lang = languageDetector();
1021
- this.inlineErrors = false;
1022
- this.readonly = null;
1023
- this.valueChange = new i0.EventEmitter();
1024
- this.keyPress = new i0.EventEmitter();
1025
- this.onChange = function (_value) { };
1026
- this.onTouched = function () { };
1027
- }
1028
- Object.defineProperty(DatetimeComponent.prototype, "className", {
1029
- get: function () {
1030
- return this.checkClassName();
1031
- },
1032
- enumerable: false,
1033
- configurable: true
1034
- });
1035
- Object.defineProperty(DatetimeComponent.prototype, "disabled", {
1036
- get: function () {
1037
- return this._disabled;
1038
- },
1039
- set: function (v) {
1040
- v = typeof v === 'string' && v !== 'false' ? true : v;
1041
- this._disabled = v;
1042
- },
1043
- enumerable: false,
1044
- configurable: true
1045
- });
1046
- Object.defineProperty(DatetimeComponent.prototype, "required", {
1047
- get: function () {
1048
- return this._required;
1049
- },
1050
- set: function (v) {
1051
- this._required = v;
1052
- },
1053
- enumerable: false,
1054
- configurable: true
1055
- });
1056
- Object.defineProperty(DatetimeComponent.prototype, "value", {
1057
- get: function () {
1058
- return this._value;
1059
- },
1060
- set: function (v) {
1061
- if (v === this._value) {
1062
- return; // prevent events when there is no changes
1063
- }
1064
- var initialAndEmpty = isInitialAndEmpty(this._value, v);
1065
- var datetime = new Date(v);
1066
- if (!v) {
1067
- this._value = null;
1068
- this.setDateInControl(null);
1069
- this.setTimeInControl(null);
1070
- }
1071
- else if (!isValidDate(datetime)) {
1072
- this._value = v;
1073
- // we don't set value in control if the value is not valid
1074
- // if we do, the content of the control changes and can erase what the user is typing
1075
- }
1076
- else {
1077
- this._value = datetime.toISOString(); // YYYY-MM-DDThh:mm:ss.SSSZ
1078
- this.setValueInControl(datetime);
1079
- }
1080
- this.onChange(v);
1081
- if (!initialAndEmpty) {
1082
- this.valueChange.emit(v);
1083
- }
1084
- },
1085
- enumerable: false,
1086
- configurable: true
1087
- });
1088
- // ControlValueAccessor Interface implementation
1089
- DatetimeComponent.prototype.writeValue = function (value) {
1090
- this.value = value;
1091
- };
1092
- DatetimeComponent.prototype.registerOnChange = function (onChange) {
1093
- this.onChange = onChange;
1094
- };
1095
- DatetimeComponent.prototype.registerOnTouched = function (onTouched) {
1096
- this.onTouched = onTouched;
1097
- };
1098
- DatetimeComponent.prototype.markAsTouched = function () {
1099
- if (!this.touched) {
1100
- this.onTouched();
1101
- this.touched = true;
1102
- }
1103
- };
1104
- DatetimeComponent.prototype.setDisabledState = function (disabled) {
1105
- this.disabled = disabled;
1106
- };
1107
- // End of ControlValueAccessor Interface implementation
1108
- DatetimeComponent.prototype.setDateInControl = function (date) {
1109
- // this.dateInput.nativeElement.value = date;
1110
- this.dateValue = date;
1111
- };
1112
- DatetimeComponent.prototype.setTimeInControl = function (time) {
1113
- // this.timeInput.nativeElement.value = time;
1114
- this.timeValue = time;
1115
- };
1116
- DatetimeComponent.prototype.setValueInControl = function (datetime) {
1117
- var offsetDatetime = this.localTime
1118
- ? addTimezoneOffset(datetime)
1119
- : datetime;
1120
- var offsetDatetimeString = offsetDatetime.toISOString(); // YYYY-MM-DDThh:mm:ss.SSSZ
1121
- this.setDateInControl(offsetDatetimeString.slice(0, 10)); // YYYY-MM-DD
1122
- if (this.includeSeconds) {
1123
- this.setTimeInControl(offsetDatetimeString.slice(11, 19)); // hh:mm:ss
1124
- }
1125
- else {
1126
- this.setTimeInControl(offsetDatetimeString.slice(11, 16)); // hh:mm
1127
- }
1128
- };
1129
- DatetimeComponent.prototype.clear = function () {
1130
- this.setDateInControl(null);
1131
- this.setTimeInControl(null);
1132
- this.value = null;
1133
- };
1134
- // Validator interface
1135
- DatetimeComponent.prototype.registerOnValidatorChange = function () { };
1136
- DatetimeComponent.prototype.validate = function (control) {
1137
- var value = control.value;
1138
- var result = null;
1139
- if (this.required &&
1140
- !hasValue(value) &&
1141
- !hasValue(this.dateValue) &&
1142
- !hasValue(this.timeValue)) {
1143
- result = result || {};
1144
- result.required = { value: value, reason: 'Required field.' };
1145
- }
1146
- if (!hasValue(this.dateValue) && hasValue(this.timeValue)) {
1147
- result = result || {};
1148
- result.existsDate = {
1149
- value: value,
1150
- reason: 'Date not specified.'
1151
- };
1152
- }
1153
- if (hasValue(this.dateValue) && !hasValue(this.timeValue)) {
1154
- result = result || {};
1155
- result.existsTime = {
1156
- value: value,
1157
- reason: 'Time not specified.'
1158
- };
1159
- }
1160
- if (hasValue(this.min) &&
1161
- hasValue(value) &&
1162
- hasValue(this.dateValue) &&
1163
- hasValue(this.timeValue) &&
1164
- String(value).localeCompare(this.min) === -1) {
1165
- result = result || {};
1166
- result.min = {
1167
- value: value,
1168
- min: this.min,
1169
- reason: "Value is lower than minimum value: " + this.min + "."
1170
- };
1171
- }
1172
- if (hasValue(this.max) &&
1173
- hasValue(value) &&
1174
- hasValue(this.dateValue) &&
1175
- hasValue(this.timeValue) &&
1176
- String(value).localeCompare(this.max) !== -1) {
1177
- result = result || {};
1178
- result.max = {
1179
- value: value,
1180
- max: this.max,
1181
- reason: "Value is greater than than maximum value: " + this.max + "."
1182
- };
1183
- }
1184
- this.lastErrors = result;
1185
- return result;
1186
- };
1187
- // End of Validator interface
1188
- DatetimeComponent.prototype.ngOnInit = function () {
1189
- this.inputId = this.inputId
1190
- ? this.inputId
1191
- : "datetime$" + DatetimeComponent.idCounter++;
1192
- this.setPatterns();
1193
- };
1194
- DatetimeComponent.prototype.onLostFocus = function () {
1195
- this.markAsTouched();
1196
- };
1197
- DatetimeComponent.prototype.onKeyPress = function (event) {
1198
- this.keyPress.emit(event);
1199
- };
1200
- DatetimeComponent.prototype.onEventDatetime = function (newDate, newTime) {
1201
- if (this.disabled || this.readonly) {
1202
- return;
1203
- }
1204
- var newValue = '' + newDate + ' ' + newTime;
1205
- if (!newValue) {
1206
- this.value = null;
1207
- }
1208
- else {
1209
- var datetime = new Date(newValue);
1210
- if (isValidDate(datetime)) {
1211
- var datetimeString = void 0;
1212
- if (this.localTime) {
1213
- datetimeString = datetime.toISOString(); // YYYY-MM-DDThh:mm:ss.SSSZ
1214
- }
1215
- else {
1216
- datetimeString = addTimezoneOffset(datetime).toISOString(); // YYYY-MM-DDThh:mm:ss.SSSZ
1217
- }
1218
- if (this.includeSeconds) {
1219
- this.value = datetimeString.slice(0, 19) + 'Z'; // YYYY-MM-DDThh:mm:ssZ
1220
- }
1221
- else {
1222
- this.value = datetimeString.slice(0, 16) + 'Z'; // YYYY-MM-DDThh:mmZ
1223
- }
1224
- }
1225
- else {
1226
- this.value = newValue;
1227
- }
1228
- }
1229
- };
1230
- DatetimeComponent.prototype.checkClassName = function () {
1231
- return this.disabled
1232
- ? this.readonly
1233
- ? 'disabled readonly'
1234
- : 'disabled'
1235
- : this.readonly
1236
- ? 'readonly'
1237
- : '';
1238
- };
1239
- DatetimeComponent.prototype.setPatterns = function () {
1240
- this.min = this.min || '1900-01-01';
1241
- this.max = this.max || '2100-01-01';
1242
- };
1243
- return DatetimeComponent;
1244
- }());
1245
- DatetimeComponent.idCounter = 0;
1246
- DatetimeComponent.decorators = [
1247
- { type: i0.Component, args: [{
1248
- selector: 'lux-datetime',
1249
- template: "<input\n #dateInput\n class=\"rounded-left prefix\"\n [ngClass]=\"className\"\n type=\"date\"\n [id]=\"inputId + '$date'\"\n [(ngModel)]=\"dateValue\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [placeholder]=\"\"\n (keyup)=\"onEventDatetime(dateInput.value, timeInput.value)\"\n (change)=\"onEventDatetime(dateInput.value, timeInput.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<input\n #timeInput\n [class]=\"(disabled || readonly) && localTime ? 'rounded-right' : ''\"\n [ngClass]=\"className\"\n type=\"time\"\n [id]=\"inputId + '$time'\"\n [(ngModel)]=\"timeValue\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [placeholder]=\"\"\n [step]=\"includeSeconds ? 1 : 60\"\n (keyup)=\"onEventDatetime(dateInput.value, timeInput.value)\"\n (change)=\"onEventDatetime(dateInput.value, timeInput.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<ng-container\n *ngIf=\"!localTime\"\n>\n <div\n [class]=\"disabled || readonly ? 'rounded-right postfix symbol' : 'postfix symbol'\"\n [ngClass]=\"className\"\n >\n <span>{{ localTime ? '' : 'UTC' }}</span>\n </div>\n</ng-container>\n<button\n #clearButton\n *ngIf=\"!(disabled || readonly)\"\n class=\"rounded-right postfix icon-clear\"\n [id]=\"inputId + '$clear'\"\n (click)=\"clear()\"\n aria-label=\"clear\"\n></button>\n\n<div *ngIf=\"inlineErrors && lastErrors && (dirty || touched)\" class=\"alert\">\n <div *ngIf=\"lastErrors.required\">\n {{ userErrors[lang].required }}\n </div>\n <div *ngIf=\"lastErrors.min\">\n {{ userErrors[lang].min.replace('$min', lastErrors.min.min) }}\n </div>\n <div *ngIf=\"lastErrors.max\">\n {{ userErrors[lang].max.replace('$max', lastErrors.max.max) }}\n </div>\n</div>\n",
1250
- providers: [
1251
- {
1252
- provide: forms.NG_VALUE_ACCESSOR,
1253
- multi: true,
1254
- useExisting: i0.forwardRef(function () { return DatetimeComponent; })
1255
- },
1256
- {
1257
- provide: forms.NG_VALIDATORS,
1258
- multi: true,
1259
- useExisting: i0.forwardRef(function () { return DatetimeComponent; })
1260
- }
1261
- ],
1262
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}:host{display:flex;align-items:stretch}.readonly{border:none}.readonly:focus{border:none;outline:none}.disabled{background-color:#f1f1f1;background-color:var(--lux-disabled-color, #f1f1f1);border-color:#6d6d6d;border-color:var(--lux-disabled-border-color, #6d6d6d)}.icon-clear{grid-row:1;grid-column:2;width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);background:url(/assets/img/filter-clear.png) no-repeat center;background:var(--lux-autocomplete-icon-clear, url(/assets/img/filter-clear.png) no-repeat center);background-size:.5rem .5rem;background-size:var(--lux-autocomplete-icon-bg-size, .5rem .5rem);z-index:1}\n"]
1263
- },] }
1264
- ];
1265
- DatetimeComponent.ctorParameters = function () { return []; };
1266
- DatetimeComponent.propDecorators = {
1267
- dateInput: [{ type: i0.ViewChild, args: ['dateInput', { static: true },] }],
1268
- timeInput: [{ type: i0.ViewChild, args: ['timeInput', { static: true },] }],
1269
- min: [{ type: i0.Input }],
1270
- max: [{ type: i0.Input }],
1271
- includeSeconds: [{ type: i0.Input }],
1272
- localTime: [{ type: i0.Input }],
1273
- lang: [{ type: i0.Input }],
1274
- inlineErrors: [{ type: i0.Input }],
1275
- inputId: [{ type: i0.Input }],
1276
- ariaLabel: [{ type: i0.Input, args: ['aria-label',] }],
1277
- readonly: [{ type: i0.Input }],
1278
- disabled: [{ type: i0.Input }],
1279
- required: [{ type: i0.Input }],
1280
- value: [{ type: i0.Input }],
1281
- valueChange: [{ type: i0.Output }],
1282
- keyPress: [{ type: i0.Output }]
1283
- };
1284
-
1285
- /**
1286
- * A service that holds the functionality for advanced handling of regular expressions
1287
- */
1288
- var RegexpService = /** @class */ (function () {
1289
- function RegexpService() {
1290
- }
1291
- RegexpService.prototype.removeOuterRoundBrackets = function (regularExpressionString) {
1292
- while (regularExpressionString[0] === '(' &&
1293
- regularExpressionString[regularExpressionString.length - 1] === ')') {
1294
- regularExpressionString = regularExpressionString.slice(1, regularExpressionString.length - 1);
1295
- }
1296
- return regularExpressionString;
1297
- };
1298
- RegexpService.prototype.isQuantifier = function (quantifier) {
1299
- switch (quantifier) {
1300
- case '{':
1301
- case '?':
1302
- case '+':
1303
- case '*':
1304
- return true;
1305
- }
1306
- return false;
1307
- };
1308
- RegexpService.prototype.parseMinimalAmountOfQuantifier = function (quantifier) {
1309
- switch (quantifier[0]) {
1310
- case '?':
1311
- case '*':
1312
- return 0;
1313
- case '+':
1314
- return 1;
1315
- case '{':
1316
- for (var index = 1; index < quantifier.length; ++index) {
1317
- if (quantifier[index] < '0' || quantifier[index] > '9') {
1318
- return Number(quantifier.slice(1, index));
1319
- }
1320
- }
1321
- }
1322
- return 0;
1323
- };
1324
- RegexpService.prototype.sliceRegexByOr = function (regularExpressionString) {
1325
- var result = [];
1326
- var slicedRegex = '';
1327
- var lastSliceIndex = 0;
1328
- var roundBracketCount = 0;
1329
- var squareBracketCount = 0;
1330
- var curlyBracketCount = 0;
1331
- var index = 0;
1332
- for (; index < regularExpressionString.length; ++index) {
1333
- switch (regularExpressionString[index]) {
1334
- case '\\':
1335
- // escape sequence; skip the next character
1336
- ++index;
1337
- break;
1338
- case '(':
1339
- roundBracketCount += 1;
1340
- break;
1341
- case ')':
1342
- roundBracketCount -= 1;
1343
- break;
1344
- case '[':
1345
- squareBracketCount += 1;
1346
- break;
1347
- case ']':
1348
- squareBracketCount -= 1;
1349
- break;
1350
- case '{':
1351
- curlyBracketCount += 1;
1352
- break;
1353
- case '}':
1354
- curlyBracketCount -= 1;
1355
- break;
1356
- case '|':
1357
- if (roundBracketCount === 0 &&
1358
- squareBracketCount === 0 &&
1359
- curlyBracketCount === 0) {
1360
- slicedRegex = this.removeOuterRoundBrackets(regularExpressionString.slice(lastSliceIndex, index));
1361
- result.push(slicedRegex);
1362
- lastSliceIndex = index + 1;
1363
- }
1364
- break;
1365
- }
1366
- }
1367
- slicedRegex = this.removeOuterRoundBrackets(regularExpressionString.slice(lastSliceIndex, index));
1368
- result.push(slicedRegex);
1369
- return result;
1370
- };
1371
- RegexpService.prototype.sliceRegexByThen = function (regularExpressionString) {
1372
- // the actual result
1373
- var resultStart = [];
1374
- // the remainder of the regex in each case
1375
- var resultRemainder = [];
1376
- var roundBracketCount = 0;
1377
- var squareBracketCount = 0;
1378
- var curlyBracketCount = 0;
1379
- for (var index = 0; index < regularExpressionString.length; ++index) {
1380
- switch (regularExpressionString[index]) {
1381
- case '\\':
1382
- // escape sequence; skip the next character
1383
- ++index;
1384
- break;
1385
- case '(':
1386
- roundBracketCount += 1;
1387
- break;
1388
- case ')':
1389
- roundBracketCount -= 1;
1390
- break;
1391
- case '[':
1392
- squareBracketCount += 1;
1393
- break;
1394
- case ']':
1395
- squareBracketCount -= 1;
1396
- break;
1397
- case '{':
1398
- curlyBracketCount += 1;
1399
- break;
1400
- case '}':
1401
- curlyBracketCount -= 1;
1402
- break;
1403
- }
1404
- if (roundBracketCount === 0 &&
1405
- squareBracketCount === 0 &&
1406
- curlyBracketCount === 0) {
1407
- if (!this.isQuantifier(regularExpressionString[index + 1])) {
1408
- resultStart.push(regularExpressionString.slice(0, index + 1));
1409
- resultRemainder.push(regularExpressionString.slice(index + 1));
1410
- }
1411
- else {
1412
- // let minimalAmountOfRepeats = parseMinimalAmountOfQuantifier(regularExpressionString.slice(index + 1));
1413
- // TODO
1414
- }
1415
- }
1416
- }
1417
- return [resultStart, resultRemainder];
1418
- };
1419
- RegexpService.prototype.suggestion = function (beginning, regularExpressionString) {
1420
- if (new RegExp(regularExpressionString).test(beginning)) {
1421
- // TODO: RETURN AN EMPTY STRING
1422
- return 'YA ES IGUAL, NO HAY MÁS QUE SUGERIR';
1423
- }
1424
- var regexOptions = this.sliceRegexByOr(regularExpressionString);
1425
- if (regexOptions.length > 1) {
1426
- for (var regexOptionIndex = 0; regexOptionIndex < regexOptions.length; ++regexOptionIndex) {
1427
- var regexParts = this.sliceRegexByThen(regexOptions[regexOptionIndex]);
1428
- var regexPartsStarts = regexParts[0];
1429
- var regexPartsRemainders = regexParts[1];
1430
- // for each option, test if the first part of the regex matches
1431
- // if it doesn't, continue
1432
- // if it does, keep checking until what part it matches
1433
- if (!new RegExp(regexPartsStarts[0]).test(beginning)) {
1434
- // if there are no more options
1435
- if (regexOptionIndex === regexOptions.length - 1) {
1436
- // we return the first option, but we could return any option
1437
- // TODO: RETURN ANY TEXT THAT MATCHES regexOptions[0]
1438
- return regexOptions[0];
1439
- }
1440
- }
1441
- else {
1442
- for (var regexPartIndex = 1; regexPartIndex < regexPartsStarts.length; ++regexPartIndex) {
1443
- if (!new RegExp(regexPartsStarts[regexPartIndex]).test(beginning)) {
1444
- // TODO: RETURN ANY TEXT THAT MATCHES regexPartsRemainders[regexPartIndex - 1]
1445
- return regexPartsRemainders[regexPartIndex - 1];
1446
- }
1447
- }
1448
- }
1449
- }
1450
- }
1451
- else if (regexOptions.length === 1) {
1452
- var regexParts = this.sliceRegexByThen(regexOptions[0]);
1453
- var regexPartsStarts = regexParts[0];
1454
- var regexPartsRemainders = regexParts[1];
1455
- if (!new RegExp(regexPartsStarts[0]).test(beginning)) {
1456
- // TODO: RETURN ANY TEXT THAT MATCHES regularExpressionString
1457
- return regularExpressionString;
1458
- }
1459
- else {
1460
- for (var regexPartIndex = 1; regexPartIndex < regexPartsStarts.length; ++regexPartIndex) {
1461
- if (!new RegExp(regexPartsStarts[regexPartIndex]).test(beginning)) {
1462
- // TODO: RETURN ANY TEXT THAT MATCHES regexPartsRemainders[regexPartIndex - 1]
1463
- return regexPartsRemainders[regexPartIndex - 1];
1464
- }
1465
- }
1466
- }
1467
- }
1468
- // TODO: RETURN AN EMPTY STRING
1469
- return 'NO DEBERÍA SER POSIBLE';
1470
- };
1471
- return RegexpService;
1472
- }());
1473
- RegexpService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function RegexpService_Factory() { return new RegexpService(); }, token: RegexpService, providedIn: "root" });
1474
- RegexpService.decorators = [
1475
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
1476
- ];
1477
- RegexpService.ctorParameters = function () { return []; };
1478
-
1479
- var InputComponent = /** @class */ (function () {
1480
- function InputComponent(regexpService) {
1481
- this.regexpService = regexpService;
1482
- this.touched = false;
1483
- this.dirty = false;
1484
- this.lastErrors = null;
1485
- this._value = '';
1486
- this._pattern = undefined;
1487
- this._regexp = undefined;
1488
- this.userErrors = {
1489
- en: {
1490
- required: 'Required field.',
1491
- min: 'Minimum value is $min.',
1492
- max: 'Maximum value is $max.',
1493
- email: 'Format should match example@example.com.'
1494
- },
1495
- es: {
1496
- required: 'El campo es obligatorio.',
1497
- min: 'El valor mínimo es $min.',
1498
- max: 'El valor máximo es $max.',
1499
- email: 'El campo debe tener un formato como ejemplo@ejemplo.com.'
1500
- }
1501
- };
1502
- this.lang = languageDetector();
1503
- this.inlineErrors = false;
1504
- this.readonly = null;
1505
- this.valueChange = new i0.EventEmitter();
1506
- this.keyPress = new i0.EventEmitter();
1507
- this.onChange = function (value) { };
1508
- this.onTouched = function () { };
1509
- }
1510
- Object.defineProperty(InputComponent.prototype, "className", {
1511
- get: function () {
1512
- return this.checkClassName();
1513
- },
1514
- enumerable: false,
1515
- configurable: true
1516
- });
1517
- Object.defineProperty(InputComponent.prototype, "disabled", {
1518
- get: function () {
1519
- return this._disabled;
1520
- },
1521
- set: function (v) {
1522
- v = typeof v === 'string' ? true : v;
1523
- this._disabled = v;
1524
- },
1525
- enumerable: false,
1526
- configurable: true
1527
- });
1528
- Object.defineProperty(InputComponent.prototype, "pattern", {
1529
- get: function () {
1530
- return this._pattern;
1531
- },
1532
- set: function (p) {
1533
- this._pattern = p;
1534
- if (p === undefined) {
1535
- this._regexp = undefined;
1536
- }
1537
- else {
1538
- try {
1539
- this._regexp = new RegExp(p);
1540
- }
1541
- catch (e) {
1542
- this._pattern = undefined;
1543
- this._regexp = undefined;
1544
- }
1545
- }
1546
- },
1547
- enumerable: false,
1548
- configurable: true
1549
- });
1550
- Object.defineProperty(InputComponent.prototype, "currency", {
1551
- get: function () {
1552
- return this._currency;
1553
- },
1554
- set: function (v) {
1555
- this._currency = v.toUpperCase();
1556
- },
1557
- enumerable: false,
1558
- configurable: true
1559
- });
1560
- Object.defineProperty(InputComponent.prototype, "placeholder", {
1561
- get: function () {
1562
- return this._placeholder ? this._placeholder : '';
1563
- },
1564
- set: function (v) {
1565
- this._placeholder = v;
1566
- },
1567
- enumerable: false,
1568
- configurable: true
1569
- });
1570
- Object.defineProperty(InputComponent.prototype, "required", {
1571
- get: function () {
1572
- return this._required;
1573
- },
1574
- set: function (v) {
1575
- this._required = v;
1576
- },
1577
- enumerable: false,
1578
- configurable: true
1579
- });
1580
- Object.defineProperty(InputComponent.prototype, "type", {
1581
- get: function () {
1582
- return this._type ? this._type : 'text';
1583
- },
1584
- set: function (v) {
1585
- this._type = v.toLowerCase();
1586
- this.domain = v.toLowerCase();
1587
- this.checkType(v);
1588
- },
1589
- enumerable: false,
1590
- configurable: true
1591
- });
1592
- Object.defineProperty(InputComponent.prototype, "value", {
1593
- get: function () {
1594
- if (this.isPercentage() || this.isPermillage() || this.isNumber()) {
1595
- var numVal = parseFloat(this._value);
1596
- if (!Number.isNaN(numVal)) {
1597
- return numVal;
1598
- }
1599
- }
1600
- return this._value;
1601
- },
1602
- set: function (v) {
1603
- v = v === undefined ? null : v;
1604
- if (v === this._value) {
1605
- return; // prevent events when there is no changes
1606
- }
1607
- var initialAndEmpty = isInitialAndEmpty(this._value, v);
1608
- if (this.type === 'date') {
1609
- v = normalizeDate(v);
1610
- }
1611
- this._value = v;
1612
- this.onChange(v);
1613
- if (!initialAndEmpty) {
1614
- this.valueChange.emit(v);
1615
- }
1616
- },
1617
- enumerable: false,
1618
- configurable: true
1619
- });
1620
- // ControlValueAccessor Interface implementation
1621
- InputComponent.prototype.writeValue = function (value) {
1622
- this.value = value;
1623
- this.setValueInControl(value);
1624
- };
1625
- InputComponent.prototype.registerOnChange = function (onChange) {
1626
- this.onChange = onChange;
1627
- };
1628
- InputComponent.prototype.registerOnTouched = function (onTouched) {
1629
- this.onTouched = onTouched;
1630
- };
1631
- InputComponent.prototype.markAsTouched = function () {
1632
- if (!this.touched) {
1633
- this.onTouched();
1634
- this.touched = true;
1635
- }
1636
- };
1637
- InputComponent.prototype.setDisabledState = function (disabled) {
1638
- this.disabled = disabled;
1639
- };
1640
- // End of ControlValueAccessor Interface implementation
1641
- InputComponent.prototype.setValueInControl = function (v) {
1642
- if (this.domain === 'date') {
1643
- v = normalizeDate(v);
1644
- }
1645
- if (this.input) {
1646
- this.input.nativeElement.value = v;
1647
- }
1648
- if (this.textarea) {
1649
- this.textarea.nativeElement.value = v;
1650
- }
1651
- };
1652
- // Validator interface
1653
- InputComponent.prototype.registerOnValidatorChange = function () { };
1654
- InputComponent.prototype.validate = function (control) {
1655
- var value = control.value;
1656
- var result = null;
1657
- if (this.required && !hasValue(value)) {
1658
- result = result || {};
1659
- result.required = { value: value, reason: 'Required field.' };
1660
- }
1661
- if (this._regexp && hasValue(value) && !this._regexp.test(value)) {
1662
- result = result || {};
1663
- result.pattern = {
1664
- value: value,
1665
- reason: "Value must follow the pattern: " + this._pattern
1666
- };
1667
- }
1668
- if (this.type === 'email' && hasValue(value) && !isValidEmail(value)) {
1669
- result = result || {};
1670
- result.email = { value: value, reason: 'Invalid email.' };
1671
- }
1672
- if (this.type === 'number' && hasValue(value) && !isValidNumber(value)) {
1673
- result = result || {};
1674
- result.numeric = { value: value, reason: 'Invalid number.' };
1675
- }
1676
- if (this.type === 'date' ||
1677
- this.type === 'time' ||
1678
- this.type === 'timestamp') {
1679
- if (typeof this.min === 'string' &&
1680
- hasValue(value) &&
1681
- String(value).localeCompare(this.min) === -1) {
1682
- result = result || {};
1683
- result.min = {
1684
- value: value,
1685
- min: this.min,
1686
- reason: "Value is lower than minimum value: " + this.min + "."
1687
- };
1688
- }
1689
- if (typeof this.max === 'string' &&
1690
- hasValue(value) &&
1691
- String(value).localeCompare(this.max) !== -1) {
1692
- result = result || {};
1693
- result.max = {
1694
- value: value,
1695
- max: this.max,
1696
- reason: "Value is greater than than maximum value: " + this.max + "."
1697
- };
1698
- }
1699
- }
1700
- if (this.type === 'percentage' ||
1701
- this.type === 'permillage' ||
1702
- this.type === 'number' ||
1703
- this.type === 'currency') {
1704
- if (hasValue(this.min) && hasValue(value) && value < +this.min) {
1705
- result = result || {};
1706
- result.min = {
1707
- value: value,
1708
- min: this.min,
1709
- reason: "Value is lower than minimum value: " + this.min + "."
1710
- };
1711
- }
1712
- if (hasValue(this.max) && hasValue(value) && value > +this.max) {
1713
- result = result || {};
1714
- result.max = {
1715
- value: value,
1716
- max: this.max,
1717
- reason: "Value is greater than than maximum value: " + this.max + "."
1718
- };
1719
- }
1720
- }
1721
- this.lastErrors = result;
1722
- return result;
1723
- };
1724
- // End of Validator interface
1725
- InputComponent.prototype.ngOnInit = function () {
1726
- this.inputId = this.inputId
1727
- ? this.inputId
1728
- : this.type + "$" + InputComponent.idCounter++;
1729
- };
1730
- InputComponent.prototype.onLostFocus = function () {
1731
- this.markAsTouched();
1732
- };
1733
- InputComponent.prototype.onKeyUp = function (newValue) {
1734
- this.value = newValue;
1735
- };
1736
- InputComponent.prototype.onChangeValue = function (newValue) {
1737
- this.value = newValue;
1738
- this.markAsTouched();
1739
- };
1740
- InputComponent.prototype.onKeyPress = function (event) {
1741
- this.keyPress.emit(event);
1742
- };
1743
- InputComponent.prototype.isNumber = function () {
1744
- return this.type === 'number';
1745
- };
1746
- InputComponent.prototype.isPercentage = function () {
1747
- return this.type === 'percentage';
1748
- };
1749
- InputComponent.prototype.isPermillage = function () {
1750
- return this.type === 'permillage';
1751
- };
1752
- InputComponent.prototype.hasPrefix = function () {
1753
- return this.currency === 'USD';
1754
- };
1755
- InputComponent.prototype.hasPostfix = function () {
1756
- return (this.currency === 'EUR' || this.isPercentage() || this.isPermillage());
1757
- };
1758
- InputComponent.prototype.checkClassName = function () {
1759
- return this.disabled
1760
- ? this.readonly
1761
- ? 'disabled readonly'
1762
- : 'disabled'
1763
- : this.readonly
1764
- ? 'readonly'
1765
- : '';
1766
- };
1767
- InputComponent.prototype.checkType = function (type) {
1768
- switch (type) {
1769
- case 'email':
1770
- this.setEmailPatterns();
1771
- break;
1772
- case 'date':
1773
- this.setDatePatterns();
1774
- break;
1775
- case 'time':
1776
- this.setTimePatterns();
1777
- break;
1778
- case 'password':
1779
- this.setPasswordPatterns();
1780
- break;
1781
- case 'number':
1782
- this.setNumberPatterns();
1783
- break;
1784
- case 'currency':
1785
- this.setCurrencyPatterns();
1786
- break;
1787
- case 'percentage':
1788
- this.setPercentagePatterns();
1789
- break;
1790
- case 'permillage':
1791
- this.setPermillagePatterns();
1792
- break;
1793
- default:
1794
- break;
1795
- }
1796
- };
1797
- InputComponent.prototype.setEmailPatterns = function () { };
1798
- InputComponent.prototype.setDatePatterns = function () {
1799
- this.min = this.min || '1900-01-01';
1800
- this.max = this.max || '2100-01-01';
1801
- };
1802
- InputComponent.prototype.setTimePatterns = function () { };
1803
- InputComponent.prototype.setPasswordPatterns = function () { };
1804
- InputComponent.prototype.setNumberPatterns = function () {
1805
- this.domain = 'number';
1806
- this.placeholder = '0';
1807
- };
1808
- InputComponent.prototype.setCurrencyPatterns = function () {
1809
- this.domain = 'number';
1810
- this.step = this.step || 0.1;
1811
- this.min = this.min || 0.0;
1812
- this.max = this.max || 10000.0;
1813
- this.value = 0.0;
1814
- };
1815
- InputComponent.prototype.setPercentagePatterns = function () {
1816
- this.domain = 'number';
1817
- this.step = this.step || 0.01;
1818
- this.min = this.min || 0.0;
1819
- this.max = this.max || 100.0;
1820
- this.placeholder = '0.00';
1821
- };
1822
- InputComponent.prototype.setPermillagePatterns = function () {
1823
- this.domain = 'number';
1824
- this.step = this.step || 0.01;
1825
- this.min = this.min || 0.0;
1826
- this.max = this.max || 1000.0;
1827
- this.placeholder = '0.00';
1828
- };
1829
- return InputComponent;
1830
- }());
1831
- InputComponent.idCounter = 0;
1832
- InputComponent.decorators = [
1833
- { type: i0.Component, args: [{
1834
- selector: 'lux-input',
1835
- template: "<div *ngIf=\"currency && currency === 'USD'\" class=\"prefix rounded-left symbol\" [ngClass]=\"className\">\n <span>$</span>\n</div>\n<input\n #input\n *ngIf=\"type !== 'textarea'\"\n [class]=\"hasPrefix() ? (hasPostfix() ? 'infix' : 'postfix rounded-right') : (hasPostfix() ? 'prefix rounded-left' : 'rounded')\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [type]=\"domain\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.min]=\"min?.toString() || undefined\"\n [attr.max]=\"max?.toString() || undefined\"\n [attr.step]=\"step?.toString() || undefined\"\n [attr.pattern]=\"pattern || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(input.value)\"\n (change)=\"onChangeValue(input.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<textarea\n #textarea\n *ngIf=\"type === 'textarea'\"\n class=\"rounded\"\n [ngClass]=\"className\"\n placement=\"top\"\n [id]=\"inputId\"\n [attr.value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.cols]=\"cols?.toString() || undefined\"\n [attr.rows]=\"rows?.toString() || undefined\"\n [placeholder]=\"placeholder\"\n (keyup)=\"onKeyUp(textarea.value)\"\n (change)=\"onChangeValue(textarea.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n></textarea>\n<div *ngIf=\"currency && currency === 'EUR'\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u20AC</span>\n</div>\n<div *ngIf=\"isPercentage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>%</span>\n</div>\n<div *ngIf=\"isPermillage()\" class=\"postfix rounded-right symbol\" [ngClass]=\"className\">\n <span>\u2030</span>\n</div>\n\n<div *ngIf=\"inlineErrors && lastErrors && (dirty || touched)\" class=\"alert\">\n <div *ngIf=\"lastErrors.required\">\n {{ userErrors[this.lang].required }}\n </div>\n <div *ngIf=\"lastErrors.email\">{{ userErrors[this.lang].email }}</div>\n <div *ngIf=\"lastErrors.min\">\n {{ userErrors[this.lang].min.replace('$min', lastErrors.min.min) }}\n </div>\n <div *ngIf=\"lastErrors.max\">\n {{ userErrors[this.lang].max.replace('$max', lastErrors.max.max) }}\n </div>\n</div>\n",
1836
- providers: [
1837
- {
1838
- provide: forms.NG_VALUE_ACCESSOR,
1839
- multi: true,
1840
- useExisting: i0.forwardRef(function () { return InputComponent; })
1841
- },
1842
- {
1843
- provide: forms.NG_VALIDATORS,
1844
- multi: true,
1845
- useExisting: i0.forwardRef(function () { return InputComponent; })
1846
- }
1847
- ],
1848
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}:host{display:flex;align-items:stretch}.readonly{border:none}.readonly:focus{border:none;outline:none}.disabled{background-color:#f1f1f1;background-color:var(--lux-disabled-color, #f1f1f1);border-color:#6d6d6d;border-color:var(--lux-disabled-border-color, #6d6d6d)}\n"]
1849
- },] }
1850
- ];
1851
- InputComponent.ctorParameters = function () { return [
1852
- { type: RegexpService }
1853
- ]; };
1854
- InputComponent.propDecorators = {
1855
- input: [{ type: i0.ViewChild, args: ['input', { static: false },] }],
1856
- textarea: [{ type: i0.ViewChild, args: ['textarea', { static: false },] }],
1857
- rows: [{ type: i0.Input }],
1858
- cols: [{ type: i0.Input }],
1859
- step: [{ type: i0.Input }],
1860
- min: [{ type: i0.Input }],
1861
- max: [{ type: i0.Input }],
1862
- lang: [{ type: i0.Input }],
1863
- inlineErrors: [{ type: i0.Input }],
1864
- inputId: [{ type: i0.Input }],
1865
- ariaLabel: [{ type: i0.Input, args: ['aria-label',] }],
1866
- readonly: [{ type: i0.Input }],
1867
- disabled: [{ type: i0.Input }],
1868
- pattern: [{ type: i0.Input }],
1869
- currency: [{ type: i0.Input }],
1870
- placeholder: [{ type: i0.Input }],
1871
- required: [{ type: i0.Input }],
1872
- type: [{ type: i0.Input }],
1873
- value: [{ type: i0.Input }],
1874
- valueChange: [{ type: i0.Output }],
1875
- keyPress: [{ type: i0.Output }]
1876
- };
1877
-
1878
- /** Filter component to query for objects. */
1879
- var FilterComponent = /** @class */ (function () {
1880
- function FilterComponent() {
1881
- this.touched = false;
1882
- this._searchValue = '';
1883
- this.disabled = false;
1884
- /** Placeholder default text. */
1885
- this.placeholder = '';
1886
- /** Search on type: (default true) Auto-search when user types in. */
1887
- this.searchOnType = true;
1888
- this.debounceValue = 300; // 300 ms
1889
- /** Search value changed by user. */
1890
- this.searchValueChange = new i0.EventEmitter();
1891
- this.subject = new rxjs.Subject();
1892
- // ControlValueAccessor Interface
1893
- this.onChange = function (value) { };
1894
- this.onTouched = function () { };
1895
- this.recreateObservable();
1896
- }
1897
- Object.defineProperty(FilterComponent.prototype, "searchValue", {
1898
- /** Search value introduced by the user. */
1899
- get: function () {
1900
- return this._searchValue;
1901
- },
1902
- set: function (v) {
1903
- v = (v || '').toString();
1904
- if (v === this._searchValue) {
1905
- return;
1906
- }
1907
- this.onChange(v);
1908
- this._searchValue = v;
1909
- },
1910
- enumerable: false,
1911
- configurable: true
1912
- });
1913
- Object.defineProperty(FilterComponent.prototype, "debounce", {
1914
- get: function () {
1915
- return this.debounceValue;
1916
- },
1917
- /** Debounce time in milliseconds. (defaults to 300 ms) */
1918
- set: function (val) {
1919
- this.debounceValue = val;
1920
- this.recreateObservable();
1921
- },
1922
- enumerable: false,
1923
- configurable: true
1924
- });
1925
- FilterComponent.prototype.writeValue = function (value) {
1926
- this.searchValue = (value || '').toString();
1927
- };
1928
- FilterComponent.prototype.registerOnChange = function (onChange) {
1929
- this.onChange = onChange;
1930
- };
1931
- FilterComponent.prototype.registerOnTouched = function (onTouched) {
1932
- this.onTouched = onTouched;
1933
- };
1934
- FilterComponent.prototype.markAsTouched = function () {
1935
- if (!this.touched) {
1936
- this.onTouched();
1937
- this.touched = true;
1938
- }
1939
- };
1940
- FilterComponent.prototype.setDisabledState = function (disabled) {
1941
- this.disabled = disabled;
1942
- };
1943
- // End ControlValueAccessor Interface
1944
- FilterComponent.prototype.ngOnInit = function () {
1945
- this.inputId = this.inputId
1946
- ? this.inputId
1947
- : "filter$" + FilterComponent.idCounter++;
1948
- };
1949
- FilterComponent.prototype.ngOnDestroy = function () {
1950
- this.freeSubscriptions();
1951
- };
1952
- FilterComponent.prototype.clear = function () {
1953
- this.searchValue = '';
1954
- this.search();
1955
- };
1956
- FilterComponent.prototype.search = function () {
1957
- this.searchValueChange.emit(this.searchValue);
1958
- };
1959
- FilterComponent.prototype.keyup = function (event, newValue) {
1960
- this.markAsTouched();
1961
- this.searchValue = newValue;
1962
- if (event.key === 'Enter') {
1963
- this.searchNow(this.searchValue);
1964
- }
1965
- if (this.searchOnType) {
1966
- this.addEvent();
1967
- }
1968
- };
1969
- FilterComponent.prototype.onInputValueChange = function (newValue) {
1970
- this.markAsTouched();
1971
- this.searchValue = newValue;
1972
- };
1973
- FilterComponent.prototype.recreateObservable = function () {
1974
- var _this = this;
1975
- this.searchValue$ = this.subject
1976
- .asObservable()
1977
- .pipe(operators.debounceTime(this.debounce));
1978
- this.freeSubscriptions();
1979
- this.sub = this.searchValue$.subscribe(function (value) {
1980
- _this.searchValueChange.emit(value);
1981
- });
1982
- };
1983
- FilterComponent.prototype.freeSubscriptions = function () {
1984
- if (this.sub) {
1985
- this.sub.unsubscribe();
1986
- this.sub = null;
1987
- }
1988
- };
1989
- FilterComponent.prototype.searchNow = function (value) {
1990
- this.searchValueChange.emit(value);
1991
- };
1992
- FilterComponent.prototype.addEvent = function () {
1993
- this.subject.next(this.searchValue);
1994
- };
1995
- return FilterComponent;
1996
- }());
1997
- FilterComponent.idCounter = 0;
1998
- FilterComponent.decorators = [
1999
- { type: i0.Component, args: [{
2000
- selector: 'lux-filter',
2001
- template: "<div class=\"filter\">\n <input\n #i0\n type=\"text\"\n [attr.aria-label]=\"ariaLabel\"\n [placeholder]=\"placeholder\"\n [id]=\"inputId\"\n [disabled]=\"disabled\"\n [value]=\"searchValue\"\n (valueChange)=\"onInputValueChange(i0.value)\"\n (keyup)=\"keyup($event, i0.value)\"\n />\n\n <button\n [class.hide]=\"!searchValue\"\n aria-label=\"Clear\"\n class=\"clear-indicator icon icon-clear\"\n (click)=\"clear()\"\n ></button>\n <i *ngIf=\"1 || searchOnType\" class=\"search-indicator icon icon-search\"></i>\n <button\n class=\"btn-search\"\n *ngIf=\"!searchOnType\"\n [disabled]=\"disabled\"\n (click)=\"search()\"\n >\n Search\n </button>\n</div>\n",
2002
- providers: [
2003
- {
2004
- provide: forms.NG_VALUE_ACCESSOR,
2005
- multi: true,
2006
- useExisting: i0.forwardRef(function () { return FilterComponent; })
2007
- }
2008
- ],
2009
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}.filter{display:grid;grid-template-columns:auto 1.5rem 1.5rem .5rem auto}.filter input{grid-row:1;grid-column-start:1;grid-column-end:4}.filter .hide{visibility:collapse}.filter .clear-indicator{grid-row:1;grid-column:2;border:none}.filter .search-indicator{grid-row:1;grid-column:3}.filter .btn-search{grid-row:1;grid-column:5}.filter .icon-search{background:url(/assets/img/filter-search.png) no-repeat center;background:var(--lux-filter-icon-search, url(/assets/img/filter-search.png) no-repeat center);background-size:1rem;background-size:var(--lux-filter-icon-bg-size, 1rem);background-position:center;width:1rem;width:var(--lux-filter-icon-width, 1rem)}.filter .icon-clear{background:url(/assets/img/filter-clear.png) no-repeat center;background:var(--lux-filter-icon-clear, url(/assets/img/filter-clear.png) no-repeat center);background-size:1rem;background-size:var(--lux-filter-icon-bg-size, 1rem);background-position:center}\n"]
2010
- },] }
2011
- ];
2012
- FilterComponent.ctorParameters = function () { return []; };
2013
- FilterComponent.propDecorators = {
2014
- disabled: [{ type: i0.Input }],
2015
- inputId: [{ type: i0.Input }],
2016
- placeholder: [{ type: i0.Input }],
2017
- searchValue: [{ type: i0.Input }],
2018
- searchOnType: [{ type: i0.Input }],
2019
- ariaLabel: [{ type: i0.Input, args: ['aria-label',] }],
2020
- debounce: [{ type: i0.Input }],
2021
- searchValueChange: [{ type: i0.Output }]
2022
- };
2023
-
2024
- var ActiveModal = /** @class */ (function () {
2025
- function ActiveModal() {
2026
- }
2027
- ActiveModal.prototype.close = function (result) { };
2028
- ActiveModal.prototype.dismiss = function (reason) { };
2029
- return ActiveModal;
2030
- }());
2031
- var ModalRef = /** @class */ (function () {
2032
- function ModalRef(_windowCmptRef, _contentRef, _backdropCmptRef, _beforeDismiss) {
2033
- var _this = this;
2034
- this._windowCmptRef = _windowCmptRef;
2035
- this._contentRef = _contentRef;
2036
- this._backdropCmptRef = _backdropCmptRef;
2037
- this._beforeDismiss = _beforeDismiss;
2038
- _windowCmptRef.instance.dismissEvent.subscribe(function (reason) {
2039
- _this.dismiss(reason);
2040
- });
2041
- this.result = new Promise(function (resolve, reject) {
2042
- _this._resolve = resolve;
2043
- _this._reject = reject;
2044
- });
2045
- this.result.then(null, function () { });
2046
- }
2047
- Object.defineProperty(ModalRef.prototype, "componentInstance", {
2048
- /**
2049
- * The instance of a component used for the modal content.
2050
- *
2051
- * When a `TemplateRef` is used as the content, will return `undefined`.
2052
- */
2053
- get: function () {
2054
- if (this._contentRef.componentRef) {
2055
- return this._contentRef.componentRef.instance;
2056
- }
2057
- },
2058
- enumerable: false,
2059
- configurable: true
2060
- });
2061
- /**
2062
- * Closes the modal with an optional `result` value.
2063
- *
2064
- * The `NgbMobalRef.result` promise will be resolved with the provided value.
2065
- */
2066
- ModalRef.prototype.close = function (result) {
2067
- if (this._windowCmptRef) {
2068
- if (this._resolve) {
2069
- this._resolve(result);
2070
- }
2071
- this._removeModalElements();
2072
- }
2073
- };
2074
- ModalRef.prototype._dismiss = function (reason) {
2075
- if (this._reject) {
2076
- this._reject(reason);
2077
- }
2078
- this._removeModalElements();
2079
- };
2080
- /**
2081
- * Dismisses the modal with an optional `reason` value.
2082
- *
2083
- * The `NgbModalRef.result` promise will be rejected with the provided value.
2084
- */
2085
- ModalRef.prototype.dismiss = function (reason) {
2086
- var _this = this;
2087
- if (this._windowCmptRef) {
2088
- if (!this._beforeDismiss) {
2089
- this._dismiss(reason);
2090
- }
2091
- else {
2092
- var dismiss = this._beforeDismiss();
2093
- if (dismiss && dismiss.then) {
2094
- dismiss.then(function (result) {
2095
- if (result !== false) {
2096
- _this._dismiss(reason);
2097
- }
2098
- }, function () { });
2099
- }
2100
- else if (dismiss !== false) {
2101
- this._dismiss(reason);
2102
- }
2103
- }
2104
- }
2105
- };
2106
- ModalRef.prototype._removeModalElements = function () {
2107
- var windowNativeEl = this._windowCmptRef.location.nativeElement;
2108
- windowNativeEl.parentNode.removeChild(windowNativeEl);
2109
- this._windowCmptRef.destroy();
2110
- if (this._backdropCmptRef) {
2111
- var backdropNativeEl = this._backdropCmptRef.location.nativeElement;
2112
- backdropNativeEl.parentNode.removeChild(backdropNativeEl);
2113
- this._backdropCmptRef.destroy();
2114
- }
2115
- if (this._contentRef && this._contentRef.viewRef) {
2116
- this._contentRef.viewRef.destroy();
2117
- }
2118
- this._windowCmptRef = null;
2119
- this._backdropCmptRef = null;
2120
- this._contentRef = null;
2121
- };
2122
- return ModalRef;
2123
- }());
2124
-
2125
- /*! *****************************************************************************
2126
- Copyright (c) Microsoft Corporation.
2127
-
2128
- Permission to use, copy, modify, and/or distribute this software for any
2129
- purpose with or without fee is hereby granted.
2130
-
2131
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2132
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2133
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2134
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2135
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2136
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2137
- PERFORMANCE OF THIS SOFTWARE.
2138
- ***************************************************************************** */
2139
- /* global Reflect, Promise */
2140
- var extendStatics = function (d, b) {
2141
- extendStatics = Object.setPrototypeOf ||
2142
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2143
- function (d, b) { for (var p in b)
2144
- if (Object.prototype.hasOwnProperty.call(b, p))
2145
- d[p] = b[p]; };
2146
- return extendStatics(d, b);
2147
- };
2148
- function __extends(d, b) {
2149
- if (typeof b !== "function" && b !== null)
2150
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2151
- extendStatics(d, b);
2152
- function __() { this.constructor = d; }
2153
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2154
- }
2155
- var __assign = function () {
2156
- __assign = Object.assign || function __assign(t) {
2157
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2158
- s = arguments[i];
2159
- for (var p in s)
2160
- if (Object.prototype.hasOwnProperty.call(s, p))
2161
- t[p] = s[p];
2162
- }
2163
- return t;
2164
- };
2165
- return __assign.apply(this, arguments);
2166
- };
2167
- function __rest(s, e) {
2168
- var t = {};
2169
- for (var p in s)
2170
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2171
- t[p] = s[p];
2172
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
2173
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2174
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2175
- t[p[i]] = s[p[i]];
2176
- }
2177
- return t;
2178
- }
2179
- function __decorate(decorators, target, key, desc) {
2180
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2181
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2182
- r = Reflect.decorate(decorators, target, key, desc);
2183
- else
2184
- for (var i = decorators.length - 1; i >= 0; i--)
2185
- if (d = decorators[i])
2186
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2187
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2188
- }
2189
- function __param(paramIndex, decorator) {
2190
- return function (target, key) { decorator(target, key, paramIndex); };
2191
- }
2192
- function __metadata(metadataKey, metadataValue) {
2193
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2194
- return Reflect.metadata(metadataKey, metadataValue);
2195
- }
2196
- function __awaiter(thisArg, _arguments, P, generator) {
2197
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2198
- return new (P || (P = Promise))(function (resolve, reject) {
2199
- function fulfilled(value) { try {
2200
- step(generator.next(value));
2201
- }
2202
- catch (e) {
2203
- reject(e);
2204
- } }
2205
- function rejected(value) { try {
2206
- step(generator["throw"](value));
2207
- }
2208
- catch (e) {
2209
- reject(e);
2210
- } }
2211
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2212
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2213
- });
2214
- }
2215
- function __generator(thisArg, body) {
2216
- var _ = { label: 0, sent: function () { if (t[0] & 1)
2217
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
2218
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
2219
- function verb(n) { return function (v) { return step([n, v]); }; }
2220
- function step(op) {
2221
- if (f)
2222
- throw new TypeError("Generator is already executing.");
2223
- while (_)
2224
- try {
2225
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
2226
- return t;
2227
- if (y = 0, t)
2228
- op = [op[0] & 2, t.value];
2229
- switch (op[0]) {
2230
- case 0:
2231
- case 1:
2232
- t = op;
2233
- break;
2234
- case 4:
2235
- _.label++;
2236
- return { value: op[1], done: false };
2237
- case 5:
2238
- _.label++;
2239
- y = op[1];
2240
- op = [0];
2241
- continue;
2242
- case 7:
2243
- op = _.ops.pop();
2244
- _.trys.pop();
2245
- continue;
2246
- default:
2247
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2248
- _ = 0;
2249
- continue;
2250
- }
2251
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
2252
- _.label = op[1];
2253
- break;
2254
- }
2255
- if (op[0] === 6 && _.label < t[1]) {
2256
- _.label = t[1];
2257
- t = op;
2258
- break;
2259
- }
2260
- if (t && _.label < t[2]) {
2261
- _.label = t[2];
2262
- _.ops.push(op);
2263
- break;
2264
- }
2265
- if (t[2])
2266
- _.ops.pop();
2267
- _.trys.pop();
2268
- continue;
2269
- }
2270
- op = body.call(thisArg, _);
2271
- }
2272
- catch (e) {
2273
- op = [6, e];
2274
- y = 0;
2275
- }
2276
- finally {
2277
- f = t = 0;
2278
- }
2279
- if (op[0] & 5)
2280
- throw op[1];
2281
- return { value: op[0] ? op[1] : void 0, done: true };
2282
- }
2283
- }
2284
- var __createBinding = Object.create ? (function (o, m, k, k2) {
2285
- if (k2 === undefined)
2286
- k2 = k;
2287
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
2288
- }) : (function (o, m, k, k2) {
2289
- if (k2 === undefined)
2290
- k2 = k;
2291
- o[k2] = m[k];
2292
- });
2293
- function __exportStar(m, o) {
2294
- for (var p in m)
2295
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
2296
- __createBinding(o, m, p);
2297
- }
2298
- function __values(o) {
2299
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2300
- if (m)
2301
- return m.call(o);
2302
- if (o && typeof o.length === "number")
2303
- return {
2304
- next: function () {
2305
- if (o && i >= o.length)
2306
- o = void 0;
2307
- return { value: o && o[i++], done: !o };
2308
- }
2309
- };
2310
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2311
- }
2312
- function __read(o, n) {
2313
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2314
- if (!m)
2315
- return o;
2316
- var i = m.call(o), r, ar = [], e;
2317
- try {
2318
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
2319
- ar.push(r.value);
2320
- }
2321
- catch (error) {
2322
- e = { error: error };
2323
- }
2324
- finally {
2325
- try {
2326
- if (r && !r.done && (m = i["return"]))
2327
- m.call(i);
2328
- }
2329
- finally {
2330
- if (e)
2331
- throw e.error;
2332
- }
2333
- }
2334
- return ar;
2335
- }
2336
- /** @deprecated */
2337
- function __spread() {
2338
- for (var ar = [], i = 0; i < arguments.length; i++)
2339
- ar = ar.concat(__read(arguments[i]));
2340
- return ar;
2341
- }
2342
- /** @deprecated */
2343
- function __spreadArrays() {
2344
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
2345
- s += arguments[i].length;
2346
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
2347
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2348
- r[k] = a[j];
2349
- return r;
2350
- }
2351
- function __spreadArray(to, from, pack) {
2352
- if (pack || arguments.length === 2)
2353
- for (var i = 0, l = from.length, ar; i < l; i++) {
2354
- if (ar || !(i in from)) {
2355
- if (!ar)
2356
- ar = Array.prototype.slice.call(from, 0, i);
2357
- ar[i] = from[i];
2358
- }
2359
- }
2360
- return to.concat(ar || Array.prototype.slice.call(from));
2361
- }
2362
- function __await(v) {
2363
- return this instanceof __await ? (this.v = v, this) : new __await(v);
2364
- }
2365
- function __asyncGenerator(thisArg, _arguments, generator) {
2366
- if (!Symbol.asyncIterator)
2367
- throw new TypeError("Symbol.asyncIterator is not defined.");
2368
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
2369
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
2370
- function verb(n) { if (g[n])
2371
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
2372
- function resume(n, v) { try {
2373
- step(g[n](v));
2374
- }
2375
- catch (e) {
2376
- settle(q[0][3], e);
2377
- } }
2378
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
2379
- function fulfill(value) { resume("next", value); }
2380
- function reject(value) { resume("throw", value); }
2381
- function settle(f, v) { if (f(v), q.shift(), q.length)
2382
- resume(q[0][0], q[0][1]); }
2383
- }
2384
- function __asyncDelegator(o) {
2385
- var i, p;
2386
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
2387
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
2388
- }
2389
- function __asyncValues(o) {
2390
- if (!Symbol.asyncIterator)
2391
- throw new TypeError("Symbol.asyncIterator is not defined.");
2392
- var m = o[Symbol.asyncIterator], i;
2393
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
2394
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
2395
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
2396
- }
2397
- function __makeTemplateObject(cooked, raw) {
2398
- if (Object.defineProperty) {
2399
- Object.defineProperty(cooked, "raw", { value: raw });
2400
- }
2401
- else {
2402
- cooked.raw = raw;
2403
- }
2404
- return cooked;
2405
- }
2406
- ;
2407
- var __setModuleDefault = Object.create ? (function (o, v) {
2408
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2409
- }) : function (o, v) {
2410
- o["default"] = v;
2411
- };
2412
- function __importStar(mod) {
2413
- if (mod && mod.__esModule)
2414
- return mod;
2415
- var result = {};
2416
- if (mod != null)
2417
- for (var k in mod)
2418
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
2419
- __createBinding(result, mod, k);
2420
- __setModuleDefault(result, mod);
2421
- return result;
2422
- }
2423
- function __importDefault(mod) {
2424
- return (mod && mod.__esModule) ? mod : { default: mod };
2425
- }
2426
- function __classPrivateFieldGet(receiver, state, kind, f) {
2427
- if (kind === "a" && !f)
2428
- throw new TypeError("Private accessor was defined without a getter");
2429
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2430
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
2431
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2432
- }
2433
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
2434
- if (kind === "m")
2435
- throw new TypeError("Private method is not writable");
2436
- if (kind === "a" && !f)
2437
- throw new TypeError("Private accessor was defined without a setter");
2438
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2439
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
2440
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2441
- }
2442
-
2443
- var FOCUS = 'focus';
2444
- var Key;
2445
- (function (Key) {
2446
- Key[Key["Tab"] = 9] = "Tab";
2447
- Key[Key["Enter"] = 13] = "Enter";
2448
- Key[Key["Escape"] = 27] = "Escape";
2449
- Key[Key["Space"] = 32] = "Space";
2450
- Key[Key["PageUp"] = 33] = "PageUp";
2451
- Key[Key["PageDown"] = 34] = "PageDown";
2452
- Key[Key["End"] = 35] = "End";
2453
- Key[Key["Home"] = 36] = "Home";
2454
- Key[Key["ArrowLeft"] = 37] = "ArrowLeft";
2455
- Key[Key["ArrowUp"] = 38] = "ArrowUp";
2456
- Key[Key["ArrowRight"] = 39] = "ArrowRight";
2457
- Key[Key["ArrowDown"] = 40] = "ArrowDown";
2458
- })(Key || (Key = {}));
2459
- var isDefined = function (value) { return value !== undefined && value !== null; };
2460
- var ContentRef = /** @class */ (function () {
2461
- function ContentRef(nodes, viewRef, componentRef) {
2462
- this.nodes = nodes;
2463
- this.viewRef = viewRef;
2464
- this.componentRef = componentRef;
2465
- }
2466
- return ContentRef;
2467
- }());
2468
- var FOCUSABLE_ELEMENTS_SELECTOR = [
2469
- 'a[href]',
2470
- 'button:not([disabled])',
2471
- 'input:not([disabled]):not([type="hidden"])',
2472
- 'select:not([disabled])',
2473
- 'textarea:not([disabled])',
2474
- '[contenteditable]',
2475
- '[tabindex]:not([tabindex="-1"])'
2476
- ].join(', ');
2477
- /**
2478
- * Returns first and last focusable elements inside of a given element based on specific CSS selector
2479
- */
2480
- var getFocusableBoundaryElements = function (element) {
2481
- var list = Array.from(element.querySelectorAll(FOCUSABLE_ELEMENTS_SELECTOR)).filter(function (el) { return el.tabIndex !== -1; });
2482
- return [list[0], list[list.length - 1]];
2483
- };
2484
- /**
2485
- * Function that enforces browser focus to be trapped inside a DOM element.
2486
- *
2487
- * Works only for clicks inside the element and navigation with 'Tab', ignoring clicks outside of the element
2488
- *
2489
- * @param element The element around which focus will be trapped inside
2490
- * @param stopFocusTrap$ The observable stream. When completed the focus trap will clean up listeners
2491
- * and free internal resources
2492
- * @param refocusOnClick Put the focus back to the last focused element whenever a click occurs on element (default to
2493
- * false)
2494
- */
2495
- var focusTrap = function (element, stopFocusTrap$, refocusOnClick) {
2496
- if (refocusOnClick === void 0) { refocusOnClick = false; }
2497
- // last focused element
2498
- var lastFocusedElement$ = rxjs.fromEvent(element, 'focusin').pipe(operators.takeUntil(stopFocusTrap$), operators.map(function (e) { return e.target; }));
2499
- // 'tab' / 'shift+tab' stream
2500
- rxjs.fromEvent(element, 'keydown')
2501
- .pipe(operators.takeUntil(stopFocusTrap$),
2502
- /* eslint-disable import/no-deprecated */
2503
- operators.filter(function (e) { return e.which === Key.Tab; }),
2504
- /* eslint-enable import/no-deprecated */
2505
- operators.withLatestFrom(lastFocusedElement$))
2506
- .subscribe(function (_a) {
2507
- var _b = __read(_a, 2), tabEvent = _b[0], focusedElement = _b[1];
2508
- var _c = __read(getFocusableBoundaryElements(element), 2), first = _c[0], last = _c[1];
2509
- if ((focusedElement === first || focusedElement === element) &&
2510
- tabEvent.shiftKey) {
2511
- last.focus();
2512
- tabEvent.preventDefault();
2513
- }
2514
- if (focusedElement === last && !tabEvent.shiftKey) {
2515
- first.focus();
2516
- tabEvent.preventDefault();
2517
- }
2518
- });
2519
- // inside click
2520
- if (refocusOnClick) {
2521
- rxjs.fromEvent(element, 'click')
2522
- .pipe(operators.takeUntil(stopFocusTrap$), operators.withLatestFrom(lastFocusedElement$), operators.map(function (arr) { return arr[1]; }))
2523
- .subscribe(function (lastFocusedElement) { return lastFocusedElement.focus(); });
2524
- }
2525
- };
2526
-
2527
- var ModalDismissReasons;
2528
- (function (ModalDismissReasons) {
2529
- ModalDismissReasons[ModalDismissReasons["BackdropClick"] = 0] = "BackdropClick";
2530
- ModalDismissReasons[ModalDismissReasons["Esc"] = 1] = "Esc";
2531
- })(ModalDismissReasons || (ModalDismissReasons = {}));
2532
-
2533
- var LuxModalWindowComponent = /** @class */ (function () {
2534
- function LuxModalWindowComponent(_document, _elRef) {
2535
- this._document = _document;
2536
- this._elRef = _elRef;
2537
- this.backdrop = false;
2538
- this.keyboard = true;
2539
- this.dismissEvent = new i0.EventEmitter();
2540
- this.role = 'dialog';
2541
- this.tabindex = '-1';
2542
- this.ariamodal = true;
2543
- }
2544
- Object.defineProperty(LuxModalWindowComponent.prototype, "class", {
2545
- get: function () {
2546
- return "modal " + (this.windowClass || '');
2547
- },
2548
- enumerable: false,
2549
- configurable: true
2550
- });
2551
- Object.defineProperty(LuxModalWindowComponent.prototype, "hostAriaLabelledBy", {
2552
- get: function () {
2553
- return this.ariaLabelledBy;
2554
- },
2555
- enumerable: false,
2556
- configurable: true
2557
- });
2558
- Object.defineProperty(LuxModalWindowComponent.prototype, "hostAriaDescribedBy", {
2559
- get: function () {
2560
- return this.ariaDescribedBy;
2561
- },
2562
- enumerable: false,
2563
- configurable: true
2564
- });
2565
- LuxModalWindowComponent.prototype.backdropClick = function (btn) {
2566
- if (this.backdrop === true && this._elRef.nativeElement === btn) {
2567
- this.dismiss(ModalDismissReasons.BackdropClick);
2568
- }
2569
- };
2570
- LuxModalWindowComponent.prototype.escKey = function (event) {
2571
- if (this.keyboard && !event.defaultPrevented) {
2572
- this.dismiss(ModalDismissReasons.Esc);
2573
- }
2574
- };
2575
- LuxModalWindowComponent.prototype.dismiss = function (reason) {
2576
- this.dismissEvent.emit(reason);
2577
- };
2578
- LuxModalWindowComponent.prototype.ngOnInit = function () {
2579
- this._elWithFocus = this._document.activeElement;
2580
- };
2581
- LuxModalWindowComponent.prototype.ngAfterViewInit = function () {
2582
- if (!this._elRef.nativeElement.contains(document.activeElement)) {
2583
- var firstFocusable = getFocusableBoundaryElements(this._elRef.nativeElement)[0];
2584
- var elementToFocus = firstFocusable || this._elRef.nativeElement;
2585
- elementToFocus.focus();
2586
- }
2587
- };
2588
- LuxModalWindowComponent.prototype.ngOnDestroy = function () {
2589
- var body = this._document.body;
2590
- var elWithFocus = this._elWithFocus;
2591
- var elementToFocus;
2592
- if (elWithFocus && elWithFocus[FOCUS] && body.contains(elWithFocus)) {
2593
- elementToFocus = elWithFocus;
2594
- }
2595
- else {
2596
- elementToFocus = body;
2597
- }
2598
- elementToFocus.focus();
2599
- this._elWithFocus = null;
2600
- };
2601
- return LuxModalWindowComponent;
2602
- }());
2603
- LuxModalWindowComponent.decorators = [
2604
- { type: i0.Component, args: [{
2605
- selector: 'lux-modal-window',
2606
- template: "\n <div class=\"modal-dialog\" role=\"document\">\n <div class=\"modal-content\"><ng-content></ng-content></div>\n </div>\n "
2607
- },] }
2608
- ];
2609
- LuxModalWindowComponent.ctorParameters = function () { return [
2610
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
2611
- { type: i0.ElementRef }
2612
- ]; };
2613
- LuxModalWindowComponent.propDecorators = {
2614
- ariaDescribedBy: [{ type: i0.Input }],
2615
- ariaLabelledBy: [{ type: i0.Input }],
2616
- backdrop: [{ type: i0.Input }],
2617
- keyboard: [{ type: i0.Input }],
2618
- windowClass: [{ type: i0.Input }],
2619
- dismissEvent: [{ type: i0.Output }],
2620
- class: [{ type: i0.HostBinding, args: ['class',] }],
2621
- role: [{ type: i0.HostBinding, args: ['attr.role',] }],
2622
- tabindex: [{ type: i0.HostBinding, args: ['tabindex',] }],
2623
- ariamodal: [{ type: i0.HostBinding, args: ['attr.aria-modal',] }],
2624
- hostAriaLabelledBy: [{ type: i0.HostBinding, args: ['attr.aria-labelledby',] }],
2625
- hostAriaDescribedBy: [{ type: i0.HostBinding, args: ['attr.aria-describedby',] }],
2626
- backdropClick: [{ type: i0.HostListener, args: ['click', ['$event.target'],] }],
2627
- escKey: [{ type: i0.HostListener, args: ['keyup.esc', ['$event'],] }]
2628
- };
2629
-
2630
- var LuxModalBackdropComponent = /** @class */ (function () {
2631
- function LuxModalBackdropComponent() {
2632
- this.class = 'modal-backdrop fade show';
2633
- this.style = 'z-index: 1050';
2634
- }
2635
- return LuxModalBackdropComponent;
2636
- }());
2637
- LuxModalBackdropComponent.decorators = [
2638
- { type: i0.Component, args: [{
2639
- selector: 'lux-modal-backdrop',
2640
- template: ''
2641
- },] }
2642
- ];
2643
- LuxModalBackdropComponent.propDecorators = {
2644
- backdropClass: [{ type: i0.Input }],
2645
- class: [{ type: i0.HostBinding, args: ['class',] }],
2646
- style: [{ type: i0.HostBinding, args: ['style',] }]
2647
- };
2648
-
2649
- var LuxModalConfig = /** @class */ (function () {
2650
- function LuxModalConfig() {
2651
- this.backdrop = true;
2652
- }
2653
- return LuxModalConfig;
2654
- }());
2655
- LuxModalConfig.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LuxModalConfig_Factory() { return new LuxModalConfig(); }, token: LuxModalConfig, providedIn: "root" });
2656
- LuxModalConfig.decorators = [
2657
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2658
- ];
2659
-
2660
- var ModalStack = /** @class */ (function () {
2661
- function ModalStack(_applicationRef, _document, _injector, _rendererFactory, modalConfig) {
2662
- var _this = this;
2663
- this._applicationRef = _applicationRef;
2664
- this._document = _document;
2665
- this._injector = _injector;
2666
- this._rendererFactory = _rendererFactory;
2667
- this.modalConfig = modalConfig;
2668
- this._activeWindowCmptHasChanged = new rxjs.Subject();
2669
- this._modalRefs = [];
2670
- this._windowCmpts = [];
2671
- this._ariaHiddenValues = new Map();
2672
- this._backdropAttributes = ['backdropClass'];
2673
- this._windowAttributes = [
2674
- 'ariaLabelledBy',
2675
- 'backdrop',
2676
- 'centered',
2677
- 'keyboard',
2678
- 'scrollable',
2679
- 'size',
2680
- 'windowClass'
2681
- ];
2682
- this._activeWindowCmptHasChanged.subscribe(function () {
2683
- if (_this._windowCmpts.length) {
2684
- var activeWindowCmpt = _this._windowCmpts[_this._windowCmpts.length - 1];
2685
- focusTrap(activeWindowCmpt.location.nativeElement, _this._activeWindowCmptHasChanged);
2686
- _this._revertAriaHidden();
2687
- _this._setAriaHidden(activeWindowCmpt.location.nativeElement);
2688
- }
2689
- });
2690
- }
2691
- ModalStack.prototype.open = function (moduleCFR, content, options) {
2692
- var _this = this;
2693
- var config = Object.assign({}, this.modalConfig, options);
2694
- var containerEl = this._document.body;
2695
- var renderer = this._rendererFactory.createRenderer(null, null);
2696
- var removeBodyClass = function () {
2697
- if (!_this._modalRefs.length) {
2698
- renderer.removeClass(_this._document.body, 'modal-open');
2699
- _this._revertAriaHidden();
2700
- }
2701
- };
2702
- var activeModal = new ActiveModal();
2703
- var contentRef = this.getContentRef(moduleCFR, content, activeModal);
2704
- var backdropCmptRef = config.backdrop ? this._attachBackdrop(moduleCFR, containerEl) : null;
2705
- var windowCmptRef = this._attachWindowComponent(moduleCFR, containerEl, contentRef);
2706
- var modalRef = new ModalRef(windowCmptRef, contentRef, backdropCmptRef);
2707
- this._registerModalRef(modalRef);
2708
- this._registerWindowCmpt(windowCmptRef);
2709
- modalRef.result.then(removeBodyClass, removeBodyClass);
2710
- activeModal.close = function (result) {
2711
- modalRef.close(result);
2712
- };
2713
- activeModal.dismiss = function (reason) {
2714
- modalRef.dismiss(reason);
2715
- };
2716
- this._applyWindowOptions(windowCmptRef.instance, config);
2717
- if (this._modalRefs.length === 1) {
2718
- renderer.addClass(this._document.body, 'modal-open');
2719
- }
2720
- if (backdropCmptRef && backdropCmptRef.instance) {
2721
- this._applyBackgroundOptions(backdropCmptRef.instance, config);
2722
- backdropCmptRef.changeDetectorRef.detectChanges();
2723
- }
2724
- windowCmptRef.changeDetectorRef.detectChanges();
2725
- return modalRef;
2726
- };
2727
- ModalStack.prototype._applyWindowOptions = function (windowInstance, config) {
2728
- this._windowAttributes.forEach(function (optionName) {
2729
- if (isDefined(config[optionName])) {
2730
- windowInstance[optionName] = config[optionName];
2731
- }
2732
- });
2733
- };
2734
- ModalStack.prototype._applyBackgroundOptions = function (backgroudInstance, config) {
2735
- this._backdropAttributes.forEach(function (optionName) {
2736
- if (isDefined(config[optionName])) {
2737
- backgroudInstance[optionName] = config[optionName];
2738
- }
2739
- });
2740
- };
2741
- ModalStack.prototype._revertAriaHidden = function () {
2742
- this._ariaHiddenValues.forEach(function (value, element) {
2743
- if (value) {
2744
- element.setAttribute('aria-hidden', value);
2745
- }
2746
- else {
2747
- element.removeAttribute('aria-hidden');
2748
- }
2749
- });
2750
- this._ariaHiddenValues.clear();
2751
- };
2752
- ModalStack.prototype.getContentRef = function (moduleCFR, content, activeModal) {
2753
- if (content instanceof i0.TemplateRef) {
2754
- return this.createFromTemplateRef(content, activeModal);
2755
- }
2756
- };
2757
- ModalStack.prototype.createFromTemplateRef = function (content, activeModal) {
2758
- var context = {
2759
- $implicit: activeModal,
2760
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
2761
- close: function (result) {
2762
- activeModal.close(result);
2763
- },
2764
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
2765
- dismiss: function (reason) {
2766
- activeModal.dismiss(reason);
2767
- }
2768
- };
2769
- var viewRef = content.createEmbeddedView(context);
2770
- this._applicationRef.attachView(viewRef);
2771
- return new ContentRef([viewRef.rootNodes], viewRef);
2772
- };
2773
- ModalStack.prototype._attachBackdrop = function (moduleCFR, containerEl) {
2774
- var backdropFactory = moduleCFR.resolveComponentFactory(LuxModalBackdropComponent);
2775
- var backdropCmptRef = backdropFactory.create(this._injector);
2776
- this._applicationRef.attachView(backdropCmptRef.hostView);
2777
- containerEl.appendChild(backdropCmptRef.location.nativeElement);
2778
- return backdropCmptRef;
2779
- };
2780
- ModalStack.prototype._attachWindowComponent = function (moduleCFR, containerEl, contentRef) {
2781
- var windowFactory = moduleCFR.resolveComponentFactory(LuxModalWindowComponent);
2782
- var windowCmptRef = windowFactory.create(this._injector, contentRef.nodes);
2783
- this._applicationRef.attachView(windowCmptRef.hostView);
2784
- containerEl.appendChild(windowCmptRef.location.nativeElement);
2785
- return windowCmptRef;
2786
- };
2787
- ModalStack.prototype._registerModalRef = function (modalRef) {
2788
- var _this = this;
2789
- var unregisterModalRef = function () {
2790
- var index = _this._modalRefs.indexOf(modalRef);
2791
- if (index > -1) {
2792
- _this._modalRefs.splice(index, 1);
2793
- }
2794
- };
2795
- this._modalRefs.push(modalRef);
2796
- modalRef.result.then(unregisterModalRef, unregisterModalRef);
2797
- };
2798
- ModalStack.prototype._registerWindowCmpt = function (windowCmpt) {
2799
- var _this = this;
2800
- this._windowCmpts.push(windowCmpt);
2801
- this._activeWindowCmptHasChanged.next();
2802
- windowCmpt.onDestroy(function () {
2803
- var index = _this._windowCmpts.indexOf(windowCmpt);
2804
- if (index > -1) {
2805
- _this._windowCmpts.splice(index, 1);
2806
- _this._activeWindowCmptHasChanged.next();
2807
- }
2808
- });
2809
- };
2810
- ModalStack.prototype._setAriaHidden = function (element) {
2811
- var _this = this;
2812
- var parent = element.parentElement;
2813
- if (parent && element !== this._document.body) {
2814
- Array.from(parent.children).forEach(function (sibling) {
2815
- if (sibling !== element && sibling.nodeName !== 'SCRIPT') {
2816
- _this._ariaHiddenValues.set(sibling, sibling.getAttribute('aria-hidden'));
2817
- sibling.setAttribute('aria-hidden', 'true');
2818
- }
2819
- });
2820
- this._setAriaHidden(parent);
2821
- }
2822
- };
2823
- return ModalStack;
2824
- }());
2825
- ModalStack.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ModalStack_Factory() { return new ModalStack(i0__namespace.ɵɵinject(i0__namespace.ApplicationRef), i0__namespace.ɵɵinject(i1__namespace.DOCUMENT), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(i0__namespace.RendererFactory2), i0__namespace.ɵɵinject(LuxModalConfig)); }, token: ModalStack, providedIn: "root" });
2826
- ModalStack.decorators = [
2827
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2828
- ];
2829
- ModalStack.ctorParameters = function () { return [
2830
- { type: i0.ApplicationRef },
2831
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
2832
- { type: i0.Injector },
2833
- { type: i0.RendererFactory2 },
2834
- { type: LuxModalConfig }
2835
- ]; };
2836
-
2837
- /**
2838
- * A service that it allow open an close modal components
2839
- */
2840
- var ModalService = /** @class */ (function () {
2841
- function ModalService(modalStack, moduleCFR) {
2842
- this.modalStack = modalStack;
2843
- this.moduleCFR = moduleCFR;
2844
- }
2845
- /**Open a modal component
2846
- * @param content TemplateRef
2847
- */
2848
- ModalService.prototype.open = function (content, options) {
2849
- if (options === void 0) { options = {}; }
2850
- return this.modalStack.open(this.moduleCFR, content, options);
2851
- };
2852
- return ModalService;
2853
- }());
2854
- ModalService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ModalService_Factory() { return new ModalService(i0__namespace.ɵɵinject(ModalStack), i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver)); }, token: ModalService, providedIn: "root" });
2855
- ModalService.decorators = [
2856
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2857
- ];
2858
- ModalService.ctorParameters = function () { return [
2859
- { type: ModalStack },
2860
- { type: i0.ComponentFactoryResolver }
2861
- ]; };
2862
-
2863
- var GeolocationService = /** @class */ (function () {
2864
- function GeolocationService(http) {
2865
- var _this = this;
2866
- this.http = http;
2867
- this.debouncePeriodMs = 300; // ms
2868
- this.cacheSize = 20;
2869
- this.lastQueriesWithResults = new Map();
2870
- this.lastQueriesLru = [];
2871
- this.currentSearch$ = new rxjs.Subject();
2872
- var typed$ = this.currentSearch$
2873
- .asObservable()
2874
- .pipe(operators.distinctUntilChanged());
2875
- this.currentQuery$ = typed$.pipe(operators.debounceTime(this.debouncePeriodMs), operators.switchMap(function (currentQuery) {
2876
- var data = _this.getFromCache(currentQuery);
2877
- if (data !== undefined) {
2878
- return rxjs.of(data);
2879
- }
2880
- // Nominatim search documentation:
2881
- // https://nominatim.org/release-docs/develop/api/Search/
2882
- var url = 'https://nominatim.openstreetmap.org/search?format=json&limit=20&q=' +
2883
- encodeURIComponent(currentQuery);
2884
- var headers = {
2885
- 'Content-Type': 'application/json'
2886
- };
2887
- _this.addToCache(currentQuery, []);
2888
- return _this.http.get(url, { headers: headers }).pipe(operators.map(function (response) {
2889
- var searchResults = response;
2890
- var uniqueResults = distinct(searchResults);
2891
- return _this.addToCache(currentQuery, uniqueResults);
2892
- }));
2893
- }));
2894
- }
2895
- GeolocationService.prototype.searchGeolocation = function (query) {
2896
- this.currentSearch$.next(query);
2897
- return this.currentQuery$;
2898
- };
2899
- GeolocationService.prototype.getLabels = function (instance, keys) {
2900
- var searchResults = instance.lastQueriesWithResults
2901
- .get(instance.getLatestQuery())
2902
- .filter(function (searchResult) { return samePosition(searchResult, keys); });
2903
- return rxjs.of(searchResults.map(function (searchResult) {
2904
- var key = {
2905
- type: 'Point',
2906
- coordinates: [searchResult.lon, searchResult.lat]
2907
- };
2908
- return {
2909
- key: key,
2910
- label: searchResult.display_name
2911
- };
2912
- }));
2913
- };
2914
- GeolocationService.prototype.getData = function (instance, search) {
2915
- return instance.searchGeolocation(search).pipe(operators.map(function (searchResults) { return searchResults.map(function (searchResult) {
2916
- var key = {
2917
- type: 'Point',
2918
- coordinates: [searchResult.lon, searchResult.lat]
2919
- };
2920
- var label = searchResult.display_name;
2921
- return { key: key, label: label };
2922
- }); }));
2923
- };
2924
- // Cache implemementation ---
2925
- GeolocationService.prototype.getFromCache = function (query) {
2926
- if (this.lastQueriesWithResults.has(query)) {
2927
- return this.lastQueriesWithResults.get(query);
2928
- }
2929
- return undefined;
2930
- };
2931
- GeolocationService.prototype.addToCache = function (query, data) {
2932
- if (this.lastQueriesWithResults.keys.length >= this.cacheSize) {
2933
- var deletedQuery = this.lastQueriesLru[0];
2934
- this.revomeFromCache(deletedQuery);
2935
- }
2936
- this.lastQueriesWithResults.set(query, data);
2937
- this.lastQueriesLru.push(query);
2938
- return data;
2939
- };
2940
- GeolocationService.prototype.revomeFromCache = function (query) {
2941
- this.lastQueriesWithResults.delete(query);
2942
- var index = this.lastQueriesLru.findIndex(function (it) { return it === query; });
2943
- this.lastQueriesLru.splice(index, 1);
2944
- };
2945
- GeolocationService.prototype.getLatestQuery = function () {
2946
- return this.lastQueriesLru.length
2947
- ? this.lastQueriesLru[this.lastQueriesLru.length - 1]
2948
- : null;
2949
- };
2950
- return GeolocationService;
2951
- }());
2952
- GeolocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function GeolocationService_Factory() { return new GeolocationService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient)); }, token: GeolocationService, providedIn: "root" });
2953
- GeolocationService.decorators = [
2954
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2955
- ];
2956
- GeolocationService.ctorParameters = function () { return [
2957
- { type: i1$1.HttpClient }
2958
- ]; };
2959
- var samePosition = function (searchResult, keys) {
2960
- var found = false;
2961
- keys.forEach(function (item) {
2962
- if (searchResult.lon === item.coordinates[0] &&
2963
- searchResult.lat === item.coordinates[1]) {
2964
- found = true;
2965
- }
2966
- });
2967
- return found;
2968
- };
2969
- var ɵ0$2 = samePosition;
2970
- var distinct = function (data) {
2971
- var unique = {};
2972
- return data.filter(function (r) {
2973
- if (unique[r.display_name]) {
2974
- return false;
2975
- }
2976
- unique[r.display_name] = 1;
2977
- return true;
2978
- });
2979
- };
2980
- var ɵ1$1 = distinct;
2981
-
2982
- var GeolocationComponent = /** @class */ (function () {
2983
- function GeolocationComponent(modalService, locationService) {
2984
- this.modalService = modalService;
2985
- this.locationService = locationService;
2986
- this.touched = false;
2987
- this.dirty = false;
2988
- this.lastErrors = null;
2989
- this.latitudeValue = undefined;
2990
- this.longitudeValue = undefined;
2991
- this.isValidNumber = isValidNumber;
2992
- this.i18n = {
2993
- en: {
2994
- lat: 'latitude',
2995
- lon: 'longitude',
2996
- selectLocation: 'Select location',
2997
- location: 'Location',
2998
- selectAction: 'Select',
2999
- cancelAction: 'Cancel',
3000
- closeAction: 'Close',
3001
- typeToSearch: 'type to search',
3002
- cardinalPoints: {
3003
- north: 'N',
3004
- south: 'S',
3005
- east: 'E',
3006
- west: 'W'
3007
- },
3008
- userErrors: {
3009
- required: 'Required field.',
3010
- minLatitude: 'Minimum latitude is $minLatitude.',
3011
- maxLatitude: 'Maximum latitude is $maxLatitude.',
3012
- minLongitude: 'Minimum longitude is $minLongitude.',
3013
- maxLongitude: 'Maximum longitude is $maxLongitude.'
3014
- }
3015
- },
3016
- es: {
3017
- lat: 'latitud',
3018
- lon: 'longitud',
3019
- selectLocation: 'Seleccione ubicación',
3020
- location: 'Ubicación',
3021
- selectAction: 'Seleccionar',
3022
- cancelAction: 'Cancelar',
3023
- closeAction: 'Cerrar',
3024
- typeToSearch: 'escribe para buscar',
3025
- cardinalPoints: {
3026
- north: 'N',
3027
- south: 'S',
3028
- east: 'E',
3029
- west: 'O'
3030
- },
3031
- userErrors: {
3032
- required: 'El campo es obligatorio.',
3033
- minLatitude: 'La latitud mínima es $minLatitude.',
3034
- maxLatitude: 'La latitud máxima es $maxLatitude.',
3035
- minLongitude: 'La longitud mínima es $minLongitude.',
3036
- maxLongitude: 'La longitud máxima es $maxLongitude.'
3037
- }
3038
- }
3039
- };
3040
- this.lang = languageDetector();
3041
- this.inlineErrors = false;
3042
- this.readonly = null;
3043
- this.valueChange = new i0.EventEmitter();
3044
- this.keyPress = new i0.EventEmitter();
3045
- this.onChange = function (value) { };
3046
- this.onTouched = function () { };
3047
- }
3048
- Object.defineProperty(GeolocationComponent.prototype, "className", {
3049
- get: function () {
3050
- return this.checkClassName();
3051
- },
3052
- enumerable: false,
3053
- configurable: true
3054
- });
3055
- Object.defineProperty(GeolocationComponent.prototype, "disabled", {
3056
- get: function () {
3057
- return this._disabled;
3058
- },
3059
- set: function (v) {
3060
- v = typeof v === 'string' && v !== 'false' ? true : v;
3061
- this._disabled = v;
3062
- },
3063
- enumerable: false,
3064
- configurable: true
3065
- });
3066
- Object.defineProperty(GeolocationComponent.prototype, "required", {
3067
- get: function () {
3068
- return this._required;
3069
- },
3070
- set: function (v) {
3071
- this._required = v;
3072
- },
3073
- enumerable: false,
3074
- configurable: true
3075
- });
3076
- Object.defineProperty(GeolocationComponent.prototype, "value", {
3077
- get: function () {
3078
- return this._value;
3079
- },
3080
- set: function (v) {
3081
- if (v === this._value) {
3082
- return; // prevent events when there is no changes
3083
- }
3084
- var initialAndEmpty = isInitialAndEmpty(this._value, v);
3085
- if (v &&
3086
- v.coordinates &&
3087
- v.coordinates.length === 2 &&
3088
- exists(v.coordinates[0] && exists(v.coordinates[1]))) {
3089
- this._value = v;
3090
- this.setLatitudeInControl(v.coordinates[1]);
3091
- this.setLongitudeInControl(v.coordinates[0]);
3092
- }
3093
- else if (!v) {
3094
- this._value = null;
3095
- this.setLatitudeInControl(null);
3096
- this.setLongitudeInControl(null);
3097
- }
3098
- else {
3099
- this._value = v;
3100
- // we don't set value in control if the value is not valid
3101
- // if we do, the content of the control changes and can erase what the user is typing
3102
- }
3103
- this.onChange(v);
3104
- if (!initialAndEmpty) {
3105
- this.valueChange.emit(v);
3106
- }
3107
- },
3108
- enumerable: false,
3109
- configurable: true
3110
- });
3111
- // ControlValueAccessor Interface implementation
3112
- GeolocationComponent.prototype.writeValue = function (value) {
3113
- this.value = value;
3114
- };
3115
- GeolocationComponent.prototype.registerOnChange = function (onChange) {
3116
- this.onChange = onChange;
3117
- };
3118
- GeolocationComponent.prototype.registerOnTouched = function (onTouched) {
3119
- this.onTouched = onTouched;
3120
- };
3121
- GeolocationComponent.prototype.markAsTouched = function () {
3122
- if (!this.touched) {
3123
- this.onTouched();
3124
- this.touched = true;
3125
- }
3126
- };
3127
- GeolocationComponent.prototype.setDisabledState = function (disabled) {
3128
- this.disabled = disabled;
3129
- };
3130
- // End of ControlValueAccessor Interface implementation
3131
- GeolocationComponent.prototype.setLatitudeInControl = function (latitude) {
3132
- // this.latitude.nativeElement.value = latitude;
3133
- this.latitudeValue = latitude;
3134
- };
3135
- GeolocationComponent.prototype.setLongitudeInControl = function (longitude) {
3136
- // this.longitude.nativeElement.value = longitude;
3137
- this.longitudeValue = longitude;
3138
- };
3139
- GeolocationComponent.prototype.clear = function () {
3140
- this.setLatitudeInControl(null);
3141
- this.setLongitudeInControl(null);
3142
- this.value = null;
3143
- };
3144
- // Validator interface
3145
- GeolocationComponent.prototype.registerOnValidatorChange = function () { };
3146
- GeolocationComponent.prototype.validate = function (control) {
3147
- var value = control.value;
3148
- var result = null;
3149
- if (this.required &&
3150
- !hasValue(value) &&
3151
- !exists(this.latitudeValue) &&
3152
- !exists(this.longitudeValue)) {
3153
- result = result || {};
3154
- result.required = { value: value, reason: 'Required field.' };
3155
- }
3156
- if (!exists(this.latitudeValue) && exists(this.longitudeValue)) {
3157
- result = result || {};
3158
- result.existsLatitude = {
3159
- value: value,
3160
- reason: 'Latitude not specified.'
3161
- };
3162
- }
3163
- if (exists(this.latitudeValue) && !exists(this.longitudeValue)) {
3164
- result = result || {};
3165
- result.existsLongitude = {
3166
- value: value,
3167
- reason: 'Longitude not specified.'
3168
- };
3169
- }
3170
- if (exists(this.minLatitude) && this.latitudeValue < this.minLatitude) {
3171
- result = result || {};
3172
- result.minLatitude = {
3173
- value: value,
3174
- min: this.minLatitude,
3175
- reason: "Latitude is lower than minimum value: " + this.minLatitude + "."
3176
- };
3177
- }
3178
- if (exists(this.maxLatitude) && this.latitudeValue > this.maxLatitude) {
3179
- result = result || {};
3180
- result.maxLatitude = {
3181
- value: value,
3182
- max: this.maxLatitude,
3183
- reason: "Latitude is higher than maximum value: " + this.maxLatitude + "."
3184
- };
3185
- }
3186
- if (exists(this.minLongitude) && this.longitudeValue < this.minLongitude) {
3187
- result = result || {};
3188
- result.minLongitude = {
3189
- value: value,
3190
- min: this.minLongitude,
3191
- reason: "Longitude is lower than minimum value: " + this.minLongitude + "."
3192
- };
3193
- }
3194
- if (exists(this.maxLongitude) && this.longitudeValue > this.maxLongitude) {
3195
- result = result || {};
3196
- result.maxLongitude = {
3197
- value: value,
3198
- max: this.maxLongitude,
3199
- reason: "Longitude is higher than maximum value: " + this.maxLongitude + "."
3200
- };
3201
- }
3202
- this.lastErrors = result;
3203
- return result;
3204
- };
3205
- // End of Validator interface
3206
- GeolocationComponent.prototype.ngOnInit = function () {
3207
- this.inputId = this.inputId
3208
- ? this.inputId
3209
- : "geolocation$" + GeolocationComponent.idCounter++;
3210
- this.setPatterns();
3211
- };
3212
- GeolocationComponent.prototype.roundToStepAndUpdateLatitudeAndLongitude = function (newLatitudeAndLongitude) {
3213
- var newLatitude = roundToMultipleOf(newLatitudeAndLongitude[1], this.step);
3214
- var newLongitude = roundToMultipleOf(newLatitudeAndLongitude[0], this.step);
3215
- if (this.disabled || this.readonly) {
3216
- return;
3217
- }
3218
- if (!exists(newLatitudeAndLongitude)) {
3219
- this.value = null;
3220
- }
3221
- this.value = {
3222
- type: 'Point',
3223
- coordinates: [newLongitude, newLatitude]
3224
- };
3225
- };
3226
- GeolocationComponent.prototype.onLostFocus = function () {
3227
- this.markAsTouched();
3228
- };
3229
- GeolocationComponent.prototype.onEventLatitude = function (newLatitude) {
3230
- if (this.disabled || this.readonly) {
3231
- return;
3232
- }
3233
- var newLatitudeValue = isValidNumber(newLatitude) ? +newLatitude : null;
3234
- if (!(exists(this.value) && exists(this.value.coordinates[0])) &&
3235
- !exists(newLatitudeValue)) {
3236
- this.value = null;
3237
- }
3238
- else {
3239
- this.value = {
3240
- type: 'Point',
3241
- coordinates: [
3242
- this.value ? this.value.coordinates[0] : undefined,
3243
- newLatitudeValue
3244
- ]
3245
- };
3246
- }
3247
- this.markAsTouched();
3248
- };
3249
- GeolocationComponent.prototype.onEventLongitude = function (newLongitude) {
3250
- if (this.disabled || this.readonly) {
3251
- return;
3252
- }
3253
- var newLongitudeValue = isValidNumber(newLongitude)
3254
- ? +newLongitude
3255
- : null;
3256
- if (!exists(newLongitudeValue) &&
3257
- !(exists(this.value) && exists(this._value.coordinates[1]))) {
3258
- this.value = null;
3259
- }
3260
- else {
3261
- this.value = {
3262
- type: 'Point',
3263
- coordinates: [
3264
- newLongitudeValue,
3265
- this.value ? this.value.coordinates[1] : undefined
3266
- ]
3267
- };
3268
- }
3269
- this.markAsTouched();
3270
- };
3271
- GeolocationComponent.prototype.onKeyPress = function (event) {
3272
- this.keyPress.emit(event);
3273
- };
3274
- GeolocationComponent.prototype.checkClassName = function () {
3275
- return this.disabled
3276
- ? this.readonly
3277
- ? 'disabled readonly'
3278
- : 'disabled'
3279
- : this.readonly
3280
- ? 'readonly'
3281
- : '';
3282
- };
3283
- GeolocationComponent.prototype.openModalMap = function (modal) {
3284
- var _this = this;
3285
- this.modalService.open(modal).result.then(function (result) {
3286
- if (result !== 'cancel') {
3287
- _this.roundToStepAndUpdateLatitudeAndLongitude(result);
3288
- }
3289
- }, function (_) { });
3290
- };
3291
- GeolocationComponent.prototype.onSearchLocationChanged = function (newValue, map) {
3292
- map.markerPoint = newValue;
3293
- map.center = map.markerPoint;
3294
- };
3295
- Object.defineProperty(GeolocationComponent.prototype, "mapTitle", {
3296
- get: function () {
3297
- return this._disabled || !!this.readonly
3298
- ? this.i18n[this.lang].location
3299
- : this.i18n[this.lang].selectLocation;
3300
- },
3301
- enumerable: false,
3302
- configurable: true
3303
- });
3304
- Object.defineProperty(GeolocationComponent.prototype, "self", {
3305
- get: function () {
3306
- return this;
3307
- },
3308
- enumerable: false,
3309
- configurable: true
3310
- });
3311
- GeolocationComponent.prototype.getLabels = function (instance, keys) {
3312
- return instance.locationService.getLabels(instance.locationService, keys);
3313
- };
3314
- GeolocationComponent.prototype.getData = function (instance, search) {
3315
- return instance.locationService.getData(instance.locationService, search);
3316
- };
3317
- GeolocationComponent.prototype.setPatterns = function () {
3318
- this.step = this.step || 0.00001; // 0.00001 degrees = 1.11 meters
3319
- this.zoom = this.zoom || 18; // (360/2^18) degrees ~ 0.00137 degrees ~ 153 meters
3320
- this.minLatitude = this.minLatitude || -90;
3321
- this.maxLatitude = this.maxLatitude || +90;
3322
- this.minLongitude = this.minLongitude || -180;
3323
- this.maxLongitude = this.maxLongitude || +180;
3324
- };
3325
- return GeolocationComponent;
3326
- }());
3327
- GeolocationComponent.idCounter = 0;
3328
- GeolocationComponent.decorators = [
3329
- { type: i0.Component, args: [{
3330
- selector: 'lux-geolocation',
3331
- template: "<input\n #latitude\n class=\"rounded-left prefix\"\n [ngClass]=\"className\"\n type=\"number\"\n [id]=\"inputId + '$latitude'\"\n [(ngModel)]=\"latitudeValue\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.min]=\"\n minLatitude !== undefined && minLatitude !== null\n ? minLatitude.toString()\n : undefined\n \"\n [attr.max]=\"\n maxLatitude !== undefined && maxLatitude !== null\n ? maxLatitude.toString()\n : undefined\n \"\n [attr.step]=\"\n step !== undefined && step !== null ? step.toString() : undefined\n \"\n [placeholder]=\"i18n[lang].lat\"\n (keyup)=\"onEventLatitude(latitude.value)\"\n (change)=\"onEventLatitude(latitude.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<div\n class=\"infix symbol clickable\"\n [ngClass]=\"className\"\n (click)=\"openModalMap(modalMap)\">\n <span *ngIf=\"isValidNumber(latitudeValue) && latitudeValue >= 0\">{{\n i18n[lang].cardinalPoints.north\n }}</span>\n <span *ngIf=\"isValidNumber(latitudeValue) && latitudeValue < 0\">{{\n i18n[lang].cardinalPoints.south\n }}</span>\n <span *ngIf=\"!isValidNumber(latitudeValue)\" class=\"icon-globe\"></span>\n</div>\n<input\n #longitude\n class=\"prefix\"\n [ngClass]=\"className\"\n type=\"number\"\n [id]=\"inputId + '$longitude'\"\n [(ngModel)]=\"longitudeValue\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.disabled]=\"disabled === true ? 'true' : undefined\"\n [attr.readonly]=\"readonly === true ? 'true' : undefined\"\n [attr.min]=\"\n minLongitude !== undefined && minLongitude !== null\n ? minLongitude.toString()\n : undefined\n \"\n [attr.max]=\"\n maxLongitude !== undefined && maxLongitude !== null\n ? maxLongitude.toString()\n : undefined\n \"\n [attr.step]=\"\n step !== undefined && step !== null ? step.toString() : undefined\n \"\n [placeholder]=\"i18n[lang].lon\"\n (keyup)=\"onEventLongitude(longitude.value)\"\n (change)=\"onEventLongitude(longitude.value)\"\n (keypress)=\"onKeyPress($event)\"\n (blur)=\"onLostFocus()\"\n/>\n<div\n [class]=\"\n disabled || readonly\n ? 'clickable rounded-right postfix symbol'\n : 'clickable postfix symbol'\n \"\n [ngClass]=\"className\"\n (click)=\"openModalMap(modalMap)\"\n>\n <span *ngIf=\"isValidNumber(longitudeValue) && longitudeValue >= 0\">{{\n i18n[lang].cardinalPoints.east\n }}</span>\n <span *ngIf=\"isValidNumber(longitudeValue) && longitudeValue < 0\">{{\n i18n[lang].cardinalPoints.west\n }}</span>\n <span *ngIf=\"!isValidNumber(longitudeValue)\" class=\"icon-globe\"></span>\n</div>\n<button\n #clearButton\n *ngIf=\"!(disabled || readonly)\"\n class=\"rounded-right postfix icon icon-clear\"\n [id]=\"inputId + '$clear'\"\n (click)=\"clear()\"\n aria-label=\"clear\"\n></button>\n\n<div *ngIf=\"inlineErrors && lastErrors && (dirty || touched)\" class=\"alert\">\n <div *ngIf=\"lastErrors.required\">\n {{ i18n[lang].userErrors.required }}\n </div>\n <div *ngIf=\"lastErrors.minLatitude\">\n {{\n i18n[lang].userErrors.minLatitude.replace(\n '$minLatitude',\n lastErrors.minLatitude.min\n )\n }}\n </div>\n <div *ngIf=\"lastErrors.maxLatitude\">\n {{\n i18n[lang].userErrors.maxLatitude.replace(\n '$maxLatitude',\n lastErrors.maxLatitude.max\n )\n }}\n </div>\n <div *ngIf=\"lastErrors.minLongitude\">\n {{\n i18n[lang].userErrors.minLongitude.replace(\n '$minLongitude',\n lastErrors.minLongitude.min\n )\n }}\n </div>\n <div *ngIf=\"lastErrors.maxLongitude\">\n {{\n i18n[lang].userErrors.maxLongitude.replace(\n '$maxLongitude',\n lastErrors.maxLongitude.max\n )\n }}\n </div>\n</div>\n\n<ng-template #modalMap let-modal>\n <div class=\"lux-modal-header\">\n <h4 class=\"modal-title\" id=\"modal-basic-title\">{{ mapTitle }}</h4>\n <button\n type=\"button\"\n class=\"close\"\n aria-label=\"Close\"\n (click)=\"modal.dismiss('Cross click')\"\n >\n <span aria-hidden=\"true\">\u00D7</span>\n </button>\n </div>\n <div class=\"lux-modal-body content\">\n <lux-autocomplete\n #searchBar\n [attr.aria-label]=\"i18n[lang].typeToSearch\"\n [placeholder]=\"i18n[lang].typeToSearch\"\n *ngIf=\"!disabled && !readonly\"\n [instance]=\"self\"\n [resolveLabelsFunction]=\"getLabels\"\n [populateFunction]=\"getData\"\n (valueChange)=\"onSearchLocationChanged(searchBar.value, map)\"\n ></lux-autocomplete>\n <div class=\"map-container\">\n <lux-map\n #map\n [center]=\"value\"\n [markerPoint]=\"value\"\n [zoom]=\"zoom\"\n [readonly]=\"readonly === true || disabled === true ? true : false\"\n ></lux-map>\n </div>\n </div>\n <div class=\"lux-modal-footer\">\n <button\n *ngIf=\"disabled || readonly\"\n type=\"button\"\n class=\"btn btn-cancel\"\n (click)=\"modal.close('cancel')\"\n >\n {{ i18n[lang].closeAction }}\n </button>\n <button\n *ngIf=\"!disabled && !readonly\"\n type=\"button\"\n class=\"btn btn-cancel\"\n (click)=\"modal.close('cancel')\"\n >\n {{ i18n[lang].cancelAction }}\n </button>\n <button\n *ngIf=\"!disabled && !readonly\"\n type=\"button\"\n class=\"btn btn-select\"\n (click)=\"modal.close(map.markerPoint.coordinates)\"\n >\n {{ i18n[lang].selectAction }}\n </button>\n </div>\n</ng-template>\n",
3332
- providers: [
3333
- {
3334
- provide: forms.NG_VALUE_ACCESSOR,
3335
- multi: true,
3336
- useExisting: i0.forwardRef(function () { return GeolocationComponent; })
3337
- },
3338
- {
3339
- provide: forms.NG_VALIDATORS,
3340
- multi: true,
3341
- useExisting: i0.forwardRef(function () { return GeolocationComponent; })
3342
- }
3343
- ],
3344
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}:host{display:flex;align-items:stretch}.btn-select{color:#fff;background-color:#4242d1;margin-left:2rem}.btn-cancel{color:#fff;background-color:#c22929}.readonly{border:none}.readonly:focus{border:none;outline:none}.disabled{background-color:#f1f1f1;background-color:var(--lux-disabled-color, #f1f1f1);border-color:#6d6d6d;border-color:var(--lux-disabled-border-color, #6d6d6d)}.icon,.icon-clear,.icon-globe{display:inline-block;background-size:1rem 1rem;background-position:center;background-repeat:no-repeat;min-width:1rem;min-height:1rem;width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);z-index:1}.clickable{cursor:pointer}.icon-globe{background:url(/assets/img/globe.svg) no-repeat center;background:var(--lux-autocomplete-icon-globe, url(/assets/img/globe.svg) no-repeat center);background-size:1rem;height:100%}.icon-clear{width:1.5rem;width:var(--lux-autocomplete-icon-width, 1.5rem);background:url(/assets/img/filter-clear.png) no-repeat center;background:var(--lux-autocomplete-icon-clear, url(/assets/img/filter-clear.png) no-repeat center);background-size:.5rem .5rem;background-size:var(--lux-autocomplete-icon-bg-size, .5rem .5rem);z-index:1}.lux-modal-body{padding:0}.map-container{height:45vh;height:var(--lux-geolocation-map-height, 45vh);width:90vw;width:var(--lux-geolocation-map-width, 90vw)}\n"]
3345
- },] }
3346
- ];
3347
- GeolocationComponent.ctorParameters = function () { return [
3348
- { type: ModalService },
3349
- { type: GeolocationService }
3350
- ]; };
3351
- GeolocationComponent.propDecorators = {
3352
- latitude: [{ type: i0.ViewChild, args: ['latitude', { static: true },] }],
3353
- longitude: [{ type: i0.ViewChild, args: ['longitude', { static: true },] }],
3354
- map: [{ type: i0.ViewChild, args: ['map', { static: false },] }],
3355
- minLatitude: [{ type: i0.Input }],
3356
- maxLatitude: [{ type: i0.Input }],
3357
- minLongitude: [{ type: i0.Input }],
3358
- maxLongitude: [{ type: i0.Input }],
3359
- step: [{ type: i0.Input }],
3360
- zoom: [{ type: i0.Input }],
3361
- lang: [{ type: i0.Input }],
3362
- inlineErrors: [{ type: i0.Input }],
3363
- inputId: [{ type: i0.Input }],
3364
- ariaLabel: [{ type: i0.Input, args: ['aria-label',] }],
3365
- readonly: [{ type: i0.Input }],
3366
- disabled: [{ type: i0.Input }],
3367
- required: [{ type: i0.Input }],
3368
- value: [{ type: i0.Input }],
3369
- valueChange: [{ type: i0.Output }],
3370
- keyPress: [{ type: i0.Output }]
3371
- };
3372
-
3373
- var Placement;
3374
- (function (Placement) {
3375
- Placement["Top"] = "top";
3376
- Placement["Bottom"] = "bottom";
3377
- Placement["Left"] = "left";
3378
- Placement["Right"] = "right";
3379
- })(Placement || (Placement = {}));
3380
-
3381
- /**
3382
- * Default Tooltip Component
3383
- */
3384
- var TooltipComponent = /** @class */ (function () {
3385
- function TooltipComponent() {
3386
- }
3387
- return TooltipComponent;
3388
- }());
3389
- TooltipComponent.decorators = [
3390
- { type: i0.Component, args: [{
3391
- template: "\n <span class=\"lux-tooltip\" style=\"transition: opacity 200ms\">{{context.message}}</span>\n "
3392
- },] }
3393
- ];
3394
- TooltipComponent.ctorParameters = function () { return []; };
3395
- TooltipComponent.propDecorators = {
3396
- context: [{ type: i0.Input }]
3397
- };
3398
-
3399
- var TooltipContentRef = /** @class */ (function () {
3400
- function TooltipContentRef(viewRef, componentRef) {
3401
- this.viewRef = viewRef;
3402
- this.componentRef = componentRef;
3403
- }
3404
- return TooltipContentRef;
3405
- }());
3406
-
3407
- var TooltipService = /** @class */ (function () {
3408
- function TooltipService(_injector, _crf, _applicationRef) {
3409
- this._injector = _injector;
3410
- this._crf = _crf;
3411
- this._applicationRef = _applicationRef;
3412
- }
3413
- TooltipService.prototype.appendComponentToBody = function (content, elHost, placement) {
3414
- var tooltipContentRef = this.getTooltipContentRef(content);
3415
- if (tooltipContentRef) {
3416
- var domElem = tooltipContentRef.viewRef
3417
- .rootNodes[0];
3418
- document.body.appendChild(domElem);
3419
- if (tooltipContentRef.componentRef) {
3420
- tooltipContentRef.componentRef.changeDetectorRef.detectChanges();
3421
- }
3422
- domElem = this.setStyle(domElem, placement);
3423
- domElem = this.setPosition(domElem, elHost, placement);
3424
- return tooltipContentRef;
3425
- }
3426
- return null;
3427
- };
3428
- TooltipService.prototype.removeComponentFromBody = function (tooltipContentRef) {
3429
- this._applicationRef.detachView(tooltipContentRef.viewRef);
3430
- if (tooltipContentRef.componentRef) {
3431
- tooltipContentRef.componentRef.destroy();
3432
- }
3433
- };
3434
- TooltipService.prototype.getTooltipContentRef = function (content) {
3435
- if (!content) {
3436
- // nothing to show
3437
- }
3438
- else if (content instanceof i0.TemplateRef) {
3439
- return this.createFromTemplateRef(content);
3440
- }
3441
- else if (typeof content === 'string') {
3442
- return this.createFromComponent(TooltipComponent, { message: content });
3443
- }
3444
- else {
3445
- return this.createFromComponent(content);
3446
- }
3447
- };
3448
- TooltipService.prototype.createFromTemplateRef = function (content) {
3449
- var viewRef = content.createEmbeddedView({});
3450
- this._applicationRef.attachView(viewRef);
3451
- return new TooltipContentRef(viewRef);
3452
- };
3453
- TooltipService.prototype.createFromComponent = function (component, context) {
3454
- var componentRef = this._crf
3455
- .resolveComponentFactory(component)
3456
- .create(this._injector);
3457
- if (context) {
3458
- componentRef.instance.context = context;
3459
- }
3460
- this._applicationRef.attachView(componentRef.hostView);
3461
- return new TooltipContentRef(componentRef.hostView, componentRef);
3462
- };
3463
- TooltipService.prototype.setStyle = function (domElem, placement) {
3464
- domElem.style.position = 'absolute';
3465
- domElem.style.minWidth = 'min-content';
3466
- domElem.style.minHeight = 'min-content';
3467
- var tooltipElement = this.getTooltipElementFromHTMLElemnt(domElem);
3468
- placement =
3469
- placement !== undefined
3470
- ? placement.toLocaleLowerCase()
3471
- : 'top'; // 'Top' is the default value of placement
3472
- tooltipElement.classList.add("lux-tooltip-" + placement);
3473
- tooltipElement.classList.add('lux-tooltip-show');
3474
- return domElem;
3475
- };
3476
- TooltipService.prototype.getTooltipElementFromHTMLElemnt = function (domElem) {
3477
- var _this = this;
3478
- var elementsArray = Array.from(domElem.classList).filter(function (className) { return className === 'lux-tooltip'; });
3479
- if (elementsArray.length !== 0) {
3480
- return domElem;
3481
- }
3482
- else if (domElem.hasChildNodes()) {
3483
- var childrenArray = Array.from(domElem.children).filter(function (child) { return _this.getTooltipElementFromHTMLElemnt(child) !== null; });
3484
- if (childrenArray.length !== 0) {
3485
- return this.getTooltipElementFromHTMLElemnt(childrenArray[0]);
3486
- }
3487
- else {
3488
- return null;
3489
- }
3490
- }
3491
- else {
3492
- return null;
3493
- }
3494
- };
3495
- TooltipService.prototype.setPosition = function (domElem, elHost, placement) {
3496
- var hostPos = elHost.nativeElement.getBoundingClientRect();
3497
- var tooltipPos = domElem.getBoundingClientRect();
3498
- var scrollPos = window.pageYOffset ||
3499
- document.documentElement.scrollTop ||
3500
- document.body.scrollTop ||
3501
- 0;
3502
- var top = 0;
3503
- var left = 0;
3504
- var offset = 10;
3505
- switch (placement) {
3506
- case Placement.Bottom:
3507
- top = hostPos.bottom + offset;
3508
- left = hostPos.left + (hostPos.width - tooltipPos.width) / 2;
3509
- break;
3510
- case Placement.Left:
3511
- top = hostPos.top + (hostPos.height - tooltipPos.height) / 2;
3512
- left = hostPos.left - tooltipPos.width - offset;
3513
- break;
3514
- case Placement.Right:
3515
- top = hostPos.top + (hostPos.height - tooltipPos.height) / 2;
3516
- left = hostPos.right + offset;
3517
- break;
3518
- case Placement.Top:
3519
- default:
3520
- top = hostPos.top - tooltipPos.height - offset;
3521
- left = hostPos.left + (hostPos.width - tooltipPos.width) / 2;
3522
- break;
3523
- }
3524
- top = Math.max(0, top);
3525
- left = Math.max(0, left);
3526
- domElem.style.top = top + scrollPos + "px";
3527
- domElem.style.left = left + "px";
3528
- return domElem;
3529
- };
3530
- return TooltipService;
3531
- }());
3532
- TooltipService.decorators = [
3533
- { type: i0.Injectable }
3534
- ];
3535
- TooltipService.ctorParameters = function () { return [
3536
- { type: i0.Injector },
3537
- { type: i0.ComponentFactoryResolver },
3538
- { type: i0.ApplicationRef }
3539
- ]; };
3540
-
3541
- /**
3542
- * Tooltip directive
3543
- */
3544
- var LuxTooltipDirective = /** @class */ (function () {
3545
- function LuxTooltipDirective(elHost, tooltipService) {
3546
- this.elHost = elHost;
3547
- this.tooltipService = tooltipService;
3548
- }
3549
- LuxTooltipDirective.prototype.onMouseEnter = function () {
3550
- if (!this.tooltipRef) {
3551
- this.tooltipRef = this.show(this.content, this.elHost, this.placement);
3552
- }
3553
- };
3554
- LuxTooltipDirective.prototype.onMouseLeave = function () {
3555
- if (this.tooltipRef) {
3556
- this.remove(this.tooltipRef);
3557
- this.tooltipRef = null;
3558
- }
3559
- };
3560
- LuxTooltipDirective.prototype.onClick = function () {
3561
- if (this.tooltipRef) {
3562
- this.remove(this.tooltipRef);
3563
- this.tooltipRef = null;
3564
- }
3565
- };
3566
- LuxTooltipDirective.prototype.show = function (component, elHost, placement) {
3567
- return this.tooltipService.appendComponentToBody(component, elHost, placement);
3568
- };
3569
- LuxTooltipDirective.prototype.remove = function (tooltipRef) {
3570
- this.tooltipService.removeComponentFromBody(tooltipRef);
3571
- };
3572
- return LuxTooltipDirective;
3573
- }());
3574
- LuxTooltipDirective.decorators = [
3575
- { type: i0.Directive, args: [{
3576
- selector: '[luxTooltip]'
3577
- },] }
3578
- ];
3579
- LuxTooltipDirective.ctorParameters = function () { return [
3580
- { type: i0.ElementRef },
3581
- { type: TooltipService }
3582
- ]; };
3583
- LuxTooltipDirective.propDecorators = {
3584
- luxTooltip: [{ type: i0.Input }],
3585
- content: [{ type: i0.Input }],
3586
- placement: [{ type: i0.Input }],
3587
- onMouseEnter: [{ type: i0.HostListener, args: ['mouseenter',] }],
3588
- onMouseLeave: [{ type: i0.HostListener, args: ['mouseleave',] }],
3589
- onClick: [{ type: i0.HostListener, args: ['click',] }]
3590
- };
3591
-
3592
- var LuxBreadcrumbComponent = /** @class */ (function () {
3593
- function LuxBreadcrumbComponent(route, activedRoute) {
3594
- this.route = route;
3595
- this.activedRoute = activedRoute;
3596
- this.subs = [];
3597
- this.imagePath = '../assets/img/arrow-forward.svg';
3598
- }
3599
- LuxBreadcrumbComponent.prototype.ngOnInit = function () {
3600
- var _this = this;
3601
- this.subs.push(this.route.events
3602
- .pipe(operators.filter(function (event) { return event instanceof router.NavigationEnd; }))
3603
- .subscribe(function (_) {
3604
- _this.breadcrumbs = [];
3605
- _this.addBreadcrumbs(_this.activedRoute.snapshot.root, true, null);
3606
- }));
3607
- };
3608
- LuxBreadcrumbComponent.prototype.ngOnDestroy = function () {
3609
- this.subs.forEach(function (s) { return s.unsubscribe(); });
3610
- this.subs = [];
3611
- };
3612
- LuxBreadcrumbComponent.prototype.addBreadcrumbs = function (activedRouteSnapshot, isRoot, urlPrefix) {
3613
- var routeConfig = activedRouteSnapshot.routeConfig;
3614
- var url = urlPrefix || '';
3615
- url += routeConfig ? '/' + this.getUrl(activedRouteSnapshot) : '';
3616
- var label = routeConfig
3617
- ? this.getLabel(activedRouteSnapshot)
3618
- : isRoot
3619
- ? 'Home'
3620
- : '';
3621
- if (label && url !== '/') {
3622
- var breadcrumb = { label: label, url: url };
3623
- this.breadcrumbs.push(breadcrumb);
3624
- }
3625
- if (activedRouteSnapshot.children.length) {
3626
- this.addBreadcrumbs(activedRouteSnapshot.children[0], false, url);
3627
- }
3628
- };
3629
- LuxBreadcrumbComponent.prototype.getUrl = function (activedRouteSnapshot) {
3630
- if (!activedRouteSnapshot.url[0]) {
3631
- return '';
3632
- }
3633
- var id = activedRouteSnapshot.params.id;
3634
- return id
3635
- ? activedRouteSnapshot.url[0] + "/" + id
3636
- : activedRouteSnapshot.routeConfig.path || '';
3637
- };
3638
- LuxBreadcrumbComponent.prototype.getLabel = function (activedRouteSnapshot) {
3639
- var routeConfig = activedRouteSnapshot.routeConfig;
3640
- if (!routeConfig) {
3641
- return null;
3642
- }
3643
- if (activedRouteSnapshot.data && activedRouteSnapshot.data.title) {
3644
- var data = activedRouteSnapshot.data;
3645
- if (data.objectTitle) {
3646
- return data.title + " " + data.objectTitle;
3647
- }
3648
- else {
3649
- return data.title;
3650
- }
3651
- }
3652
- return activedRouteSnapshot.params.id || routeConfig.path;
3653
- };
3654
- return LuxBreadcrumbComponent;
3655
- }());
3656
- LuxBreadcrumbComponent.decorators = [
3657
- { type: i0.Component, args: [{
3658
- selector: 'lux-breadcrumb',
3659
- template: "<ul class=\"lux-breadcrumb\">\n <li *ngFor=\"let breadcrumb of breadcrumbs; last as isLast; first as isFirst\"\n class=\"lux-breadcrumb-item\">\n <a [class.first]=\"isFirst\" routerLink=\"{{ breadcrumb.url }}\">{{ breadcrumb.label }}</a>\n <div *ngIf=\"!isLast\" class=\"lux-breadcrumb-separator\"></div>\n </li>\n</ul>\n",
3660
- styles: [".lux-breadcrumb{padding:10px 12px;list-style:none;list-style-type:none}.lux-breadcrumb li{display:inline;font-size:.8em}.lux-breadcrumb li a.first{font-weight:bold}.lux-breadcrumb li+li:before{padding:8px;color:#000}.lux-breadcrumb li a{text-decoration:underline}ol.lux-breadcrumb li a:hover{text-decoration:underline}.lux-breadcrumb a{cursor:hand}.lux-breadcrumb-separator{color:red;position:relative;top:5px;height:16px;padding:0 8px;background-image:url(\"data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 viewBox%3D%220 0 512 512%22%3E %3Cpath d%3D%22M294.1 256L167 129c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.3 34 0L345 239c9.1 9.1 9.3 23.7.7 33.1L201.1 417c-4.7 4.7-10.9 7-17 7s-12.3-2.3-17-7c-9.4-9.4-9.4-24.6 0-33.9l127-127.1z%22%2F%3E%3C%2Fsvg%3E\");background-repeat:no-repeat;display:inline-block}\n"]
3661
- },] }
3662
- ];
3663
- LuxBreadcrumbComponent.ctorParameters = function () { return [
3664
- { type: router.Router },
3665
- { type: router.ActivatedRoute }
3666
- ]; };
3667
-
3668
- var openLayersIsInstalled = false;
3669
- var OpenLayerLoaderService = /** @class */ (function () {
3670
- function OpenLayerLoaderService() {
3671
- }
3672
- OpenLayerLoaderService.prototype.load = function () {
3673
- if (window.ol) {
3674
- return rxjs.of(true);
3675
- }
3676
- var openLayerJsUrl = 'https://openlayers.org/en/v5.3.0/build/ol.js';
3677
- var openLayerCssUrl = 'https://openlayers.org/en/v5.3.0/css/ol.css';
3678
- if (!openLayersIsInstalled) {
3679
- openLayersIsInstalled = true; // only try to install it once
3680
- loadCss(openLayerCssUrl, function () { });
3681
- return rxjs.from(new Promise(function (resolve, _) {
3682
- loadScript(openLayerJsUrl, function () { return resolve(true); });
3683
- }));
3684
- }
3685
- return rxjs.of(true);
3686
- };
3687
- return OpenLayerLoaderService;
3688
- }());
3689
- OpenLayerLoaderService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function OpenLayerLoaderService_Factory() { return new OpenLayerLoaderService(); }, token: OpenLayerLoaderService, providedIn: "root" });
3690
- OpenLayerLoaderService.decorators = [
3691
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
3692
- ];
3693
- /** Dynamically load a script from url and return a callback */
3694
- var loadScript = function (url, callback) {
3695
- var script = document.createElement('script');
3696
- script.type = 'text/javascript';
3697
- if (script.readyState) {
3698
- // for old IE
3699
- script.onreadystatechange = function () {
3700
- if (script.readyState === 'loaded' || script.readyState === 'complete') {
3701
- script.onreadystatechange = null;
3702
- callback();
3703
- }
3704
- };
3705
- }
3706
- else {
3707
- // Others browsers
3708
- script.onload = function () {
3709
- callback();
3710
- };
3711
- }
3712
- script.src = url;
3713
- document.getElementsByTagName('head')[0].appendChild(script);
3714
- };
3715
- var ɵ0$1 = loadScript;
3716
- /** Dynamically load css from url and return a callback */
3717
- var loadCss = function (url, callback) {
3718
- var link = document.createElement('link');
3719
- link.type = 'text/css';
3720
- link.rel = 'stylesheet';
3721
- link.type = 'text/javascript';
3722
- link.href = url;
3723
- link.onload = function () {
3724
- callback();
3725
- };
3726
- document.getElementsByTagName('head')[0].appendChild(link);
3727
- };
3728
- var ɵ1 = loadCss;
3729
-
3730
- var MapComponent = /** @class */ (function () {
3731
- function MapComponent(olLoader) {
3732
- var _this = this;
3733
- this.loaded$ = new rxjs.BehaviorSubject(false);
3734
- this.valueChange = new i0.EventEmitter();
3735
- olLoader.load().subscribe(function (_) {
3736
- // Initialize
3737
- _this._markerSource = new ol.source.Vector();
3738
- _this._markerStyle = new ol.style.Style({
3739
- image: new ol.style.Icon({
3740
- anchor: [0.5, 1],
3741
- scale: 0.25,
3742
- src: '/assets/img/marker.png'
3743
- })
3744
- });
3745
- _this.loaded$.next(true);
3746
- });
3747
- }
3748
- Object.defineProperty(MapComponent.prototype, "zoom", {
3749
- get: function () {
3750
- return this._zoom;
3751
- },
3752
- set: function (zoom) {
3753
- if (!isNaN(zoom)) {
3754
- this._zoom = zoom;
3755
- if (this._map) {
3756
- this._map.getView().setZoom(zoom);
3757
- }
3758
- }
3759
- },
3760
- enumerable: false,
3761
- configurable: true
3762
- });
3763
- Object.defineProperty(MapComponent.prototype, "center", {
3764
- get: function () {
3765
- return this._center;
3766
- },
3767
- set: function (center) {
3768
- if (center && center.coordinates && center.coordinates.length === 2) {
3769
- this._center = center;
3770
- if (this._map) {
3771
- this._map.getView().setCenter(ol.proj.fromLonLat(center.coordinates));
3772
- }
3773
- }
3774
- },
3775
- enumerable: false,
3776
- configurable: true
3777
- });
3778
- Object.defineProperty(MapComponent.prototype, "readonly", {
3779
- get: function () {
3780
- return this._readonly;
3781
- },
3782
- set: function (readonly) {
3783
- var _this = this;
3784
- if (!readonly) {
3785
- if (this._map) {
3786
- this._map.on('click', function (args) {
3787
- // args.coordinate is in EPSG:3857 (meters), we transform it into EPSG:4326 (degrees)
3788
- var coordinates = ol.proj.toLonLat(args.coordinate);
3789
- // alternatively: const lonLat = ol.proj.transform(args.coordinate,'EPSG:3857','EPSG:4326');
3790
- _this.addMarkerAtCoordinates(coordinates);
3791
- });
3792
- this._map.on('pointermove', function (event) {
3793
- var pixel = _this._map.getEventPixel(event.originalEvent);
3794
- var hit = _this._map.hasFeatureAtPixel(pixel);
3795
- _this._map.getViewport().style.cursor = hit ? 'move' : 'grab';
3796
- });
3797
- }
3798
- }
3799
- else {
3800
- if (this._map) {
3801
- this._map.on('click', function (args) { });
3802
- this._map.on('pointermove', function (event) { });
3803
- this._map.getViewport().style.cursor = 'grab';
3804
- }
3805
- }
3806
- this._readonly = readonly;
3807
- // reset marker coordinates so marker interactions can be created or recreated accordingly
3808
- // to the changes to readonly
3809
- this.markerCoordinates = this.markerCoordinates;
3810
- },
3811
- enumerable: false,
3812
- configurable: true
3813
- });
3814
- Object.defineProperty(MapComponent.prototype, "markerCoordinates", {
3815
- get: function () {
3816
- return this._markerCoordinates;
3817
- },
3818
- set: function (markerCoordinates) {
3819
- if (markerCoordinates && markerCoordinates.length === 2) {
3820
- this._markerCoordinates = markerCoordinates;
3821
- if (this._map) {
3822
- this.addMarkerAtCoordinates(markerCoordinates);
3823
- }
3824
- }
3825
- else {
3826
- this._markerCoordinates = undefined;
3827
- if (this._map) {
3828
- this.removeMarker();
3829
- }
3830
- }
3831
- },
3832
- enumerable: false,
3833
- configurable: true
3834
- });
3835
- Object.defineProperty(MapComponent.prototype, "markerPoint", {
3836
- get: function () {
3837
- return {
3838
- type: 'Point',
3839
- coordinates: this.markerCoordinates
3840
- };
3841
- },
3842
- set: function (markerPoint) {
3843
- if (!markerPoint ||
3844
- !(markerPoint.coordinates && markerPoint.coordinates.length === 2)) {
3845
- this.markerCoordinates = undefined;
3846
- }
3847
- else {
3848
- this.markerCoordinates = [
3849
- +markerPoint.coordinates[0],
3850
- +markerPoint.coordinates[1]
3851
- ];
3852
- }
3853
- this.valueChange.emit(markerPoint);
3854
- },
3855
- enumerable: false,
3856
- configurable: true
3857
- });
3858
- MapComponent.prototype.ngOnInit = function () {
3859
- this.mapId = this.mapId ? this.mapId : 'map' + MapComponent.idCounter++;
3860
- };
3861
- MapComponent.prototype.ngAfterViewInit = function () {
3862
- var _this = this;
3863
- this.loaded$.subscribe(function (loaded) {
3864
- if (loaded) {
3865
- _this.initMap();
3866
- }
3867
- });
3868
- };
3869
- MapComponent.prototype.initMap = function () {
3870
- var _this = this;
3871
- this._map = new ol.Map({
3872
- target: this.mapId,
3873
- controls: ol.control.defaults({ attribution: false }),
3874
- layers: [
3875
- new ol.layer.Tile({
3876
- source: new ol.source.OSM()
3877
- }),
3878
- new ol.layer.Vector({
3879
- source: this._markerSource,
3880
- style: this._markerStyle
3881
- })
3882
- ],
3883
- view: new ol.View({
3884
- center: ol.proj.fromLonLat(this.center !== undefined ? this.center.coordinates : [0, 0]),
3885
- zoom: this.zoom
3886
- })
3887
- });
3888
- if (this.center === undefined || this.center === null) {
3889
- // if the center is not set, we set its default value
3890
- if ('geolocation' in navigator) {
3891
- navigator.geolocation.getCurrentPosition(function (position) {
3892
- _this.center = {
3893
- type: 'Point',
3894
- coordinates: [position.coords.longitude, position.coords.latitude]
3895
- };
3896
- }, function (error) {
3897
- _this.center = {
3898
- type: 'Point',
3899
- coordinates: [0, 0]
3900
- };
3901
- });
3902
- }
3903
- else {
3904
- this.center = {
3905
- type: 'Point',
3906
- coordinates: [0, 0]
3907
- };
3908
- }
3909
- }
3910
- else {
3911
- // the center needs the map to be properly set, so if it was set before the map was initialized,
3912
- // we set the center again to perform necessary adjustements
3913
- this.center = this.center;
3914
- }
3915
- if (this.zoom === undefined || this.zoom === null) {
3916
- // if the zoom is not set, we set its default value
3917
- this.zoom = 18;
3918
- }
3919
- else {
3920
- // the zoom needs the map to be properly set, so if it was set before the map was initialized,
3921
- // we set the zoom again to perform necessary adjustements
3922
- this.zoom = this.zoom;
3923
- }
3924
- if (this.readonly === undefined || this.readonly === null) {
3925
- // if readonly is not set, we set its default value
3926
- this.readonly = false;
3927
- }
3928
- else {
3929
- // readonly needs the map to be properly set, so if it was set before the map was initialized,
3930
- // we set readonly again to perform necessary adjustements
3931
- this.readonly = this.readonly;
3932
- }
3933
- if (this.markerCoordinates !== undefined &&
3934
- this.markerCoordinates !== null) {
3935
- // the marker coordinates need the map to be properly set, so if they were set before the map was initialized,
3936
- // we set the marker coordinates again to perform necessary adjustements
3937
- this.markerCoordinates = this.markerCoordinates;
3938
- }
3939
- };
3940
- MapComponent.prototype.addMarkerAtCoordinates = function (coordinates) {
3941
- var _this = this;
3942
- if (coordinates && coordinates.length === 2) {
3943
- if (this._marker !== undefined) {
3944
- this.removeMarker();
3945
- }
3946
- this._marker = new ol.Feature({
3947
- geometry: new ol.geom.Point(
3948
- // [lon, lat] is in EPSG:4326 (degrees), we transform it into EPSG:3857 (meters)
3949
- ol.proj.transform(coordinates, 'EPSG:4326', 'EPSG:3857'))
3950
- });
3951
- this._markerSource.addFeature(this._marker);
3952
- this._markerCoordinates = this.getMarkerCoordinates();
3953
- if (!this.readonly) {
3954
- var dragInteraction = new ol.interaction.Modify({
3955
- features: new ol.Collection([this._marker]),
3956
- style: this._markerStyle,
3957
- pixelTolerance: 50,
3958
- hitDetection: true
3959
- });
3960
- this._markerInteraction = dragInteraction;
3961
- this._map.addInteraction(dragInteraction);
3962
- }
3963
- this._marker.on('change', function () {
3964
- _this._markerCoordinates = _this.getMarkerCoordinates();
3965
- }, this._marker);
3966
- }
3967
- };
3968
- MapComponent.prototype.removeMarker = function () {
3969
- if (this._marker !== undefined) {
3970
- this._markerSource.removeFeature(this._marker);
3971
- this._marker = undefined;
3972
- }
3973
- if (this._markerInteraction !== undefined) {
3974
- this._map.getInteractions().pop();
3975
- this._markerInteraction = undefined;
3976
- }
3977
- };
3978
- MapComponent.prototype.getMarkerCoordinates = function () {
3979
- if (this._marker === undefined || this._marker == null) {
3980
- return this._marker;
3981
- }
3982
- var coordinates = this._marker.getGeometry().getCoordinates();
3983
- // coordinates is in EPSG:3857 (meters), we transform it into EPSG:4326 (degrees)
3984
- return ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
3985
- };
3986
- MapComponent.prototype.onResize = function () {
3987
- if (this._map) {
3988
- this._map.updateSize();
3989
- }
3990
- };
3991
- return MapComponent;
3992
- }());
3993
- MapComponent.idCounter = 0;
3994
- MapComponent.decorators = [
3995
- { type: i0.Component, args: [{
3996
- selector: 'lux-map',
3997
- template: "<div [id]=\"mapId\" class=\"map\" (resized)=\"onResize()\"></div>\n",
3998
- styles: [".map{min-height:100px;height:100%;min-width:160px;width:100%}\n"]
3999
- },] }
4000
- ];
4001
- MapComponent.ctorParameters = function () { return [
4002
- { type: OpenLayerLoaderService }
4003
- ]; };
4004
- MapComponent.propDecorators = {
4005
- mapId: [{ type: i0.Input }],
4006
- zoom: [{ type: i0.Input }],
4007
- center: [{ type: i0.Input }],
4008
- readonly: [{ type: i0.Input }],
4009
- markerCoordinates: [{ type: i0.Input }],
4010
- markerPoint: [{ type: i0.Input }],
4011
- valueChange: [{ type: i0.Output }]
4012
- };
4013
-
4014
- var PaginationComponent = /** @class */ (function () {
4015
- function PaginationComponent() {
4016
- this.literals = {
4017
- en: {
4018
- first: 'First',
4019
- previous: 'Previous',
4020
- next: 'Next',
4021
- last: 'Last'
4022
- },
4023
- es: {
4024
- first: 'Primero',
4025
- previous: 'Anterior',
4026
- next: 'Siguiente',
4027
- last: 'Último'
4028
- }
4029
- };
4030
- this.showPagination = false;
4031
- this.hidePrevious = false;
4032
- this.lastPage = false;
4033
- this.totalPages = 0;
4034
- this.displayNextEllipsis = false;
4035
- this.displayPreviousEllipsis = false;
4036
- this.pages = [];
4037
- this.goToPage = new i0.EventEmitter();
4038
- this.pageSizeChange = new i0.EventEmitter();
4039
- this.lang = languageDetector();
4040
- }
4041
- Object.defineProperty(PaginationComponent.prototype, "lang", {
4042
- get: function () {
4043
- return this._lang;
4044
- },
4045
- set: function (l) {
4046
- if (l === this._lang) {
4047
- return;
4048
- }
4049
- if (Object.keys(this.literals).includes(l)) {
4050
- this._lang = l;
4051
- }
4052
- else {
4053
- this._lang = 'en';
4054
- }
4055
- this.loadLanguage();
4056
- },
4057
- enumerable: false,
4058
- configurable: true
4059
- });
4060
- Object.defineProperty(PaginationComponent.prototype, "paginationInfo", {
4061
- get: function () {
4062
- return this.paginationInfoValue;
4063
- },
4064
- set: function (value) {
4065
- this.paginationInfoValue = value;
4066
- this.syncState();
4067
- },
4068
- enumerable: false,
4069
- configurable: true
4070
- });
4071
- PaginationComponent.prototype.ngOnInit = function () {
4072
- this.calculatePages();
4073
- };
4074
- PaginationComponent.prototype.pageSizeChanged = function (pageSize) {
4075
- this.paginationInfo.pageSize = pageSize;
4076
- this.syncState();
4077
- this.pageSizeChange.emit(pageSize);
4078
- };
4079
- PaginationComponent.prototype.onPage = function (n) {
4080
- this.goToPage.emit(n);
4081
- };
4082
- PaginationComponent.prototype.onFirst = function () {
4083
- this.goToPage.emit(0);
4084
- };
4085
- PaginationComponent.prototype.onLast = function () {
4086
- this.goToPage.emit(this.totalPages - 1);
4087
- };
4088
- PaginationComponent.prototype.onNext = function () {
4089
- var page = (this.paginationInfo.page || 0) + 1;
4090
- this.goToPage.emit(page);
4091
- };
4092
- PaginationComponent.prototype.onPrevious = function () {
4093
- var page = (this.paginationInfo.page || 0) - 1;
4094
- this.goToPage.emit(page);
4095
- };
4096
- PaginationComponent.prototype.syncState = function () {
4097
- this.pages = this.calculatePages();
4098
- this.showPagination =
4099
- this.paginationInfo.total > this.paginationInfo.pageSize;
4100
- this.hidePrevious = this.paginationInfo.page === 0;
4101
- this.lastPage =
4102
- this.paginationInfo.pageSize * (this.paginationInfo.page + 1) >=
4103
- this.paginationInfo.total;
4104
- this.totalPages =
4105
- Math.ceil(this.paginationInfo.total / this.paginationInfo.pageSize) || 0;
4106
- this.displayNextEllipsis = !this.pages.includes(this.totalPages - 1);
4107
- this.displayPreviousEllipsis = !this.pages.includes(0);
4108
- };
4109
- PaginationComponent.prototype.calculatePages = function () {
4110
- var totalPages = Math.ceil(this.paginationInfo.total / this.paginationInfo.pageSize) - 1; // 0-index
4111
- var p = this.paginationInfo.page || 0;
4112
- var pagesToShow = this.paginationInfo.pagesToShow;
4113
- var pages = [];
4114
- pages.push(p);
4115
- var times = pagesToShow - 1;
4116
- for (var i = 0; i < times; i++) {
4117
- if (pages.length < pagesToShow) {
4118
- if (Math.min.apply(Math, __spreadArray([], __read(pages))) > 0) {
4119
- pages.unshift(Math.min.apply(Math, __spreadArray([], __read(pages))) - 1);
4120
- }
4121
- }
4122
- if (pages.length < pagesToShow) {
4123
- if (Math.max.apply(Math, __spreadArray([], __read(pages))) < totalPages) {
4124
- pages.push(Math.max.apply(Math, __spreadArray([], __read(pages))) + 1);
4125
- }
4126
- }
4127
- }
4128
- pages.sort(function (a, b) { return a - b; });
4129
- return pages;
4130
- };
4131
- PaginationComponent.prototype.loadLanguage = function () {
4132
- var l = this.literals[this.lang];
4133
- this.first = l.first;
4134
- this.previous = l.previous;
4135
- this.next = l.next;
4136
- this.last = l.last;
4137
- };
4138
- return PaginationComponent;
4139
- }());
4140
- PaginationComponent.decorators = [
4141
- { type: i0.Component, args: [{
4142
- selector: 'lux-pagination',
4143
- template: "<div class=\"lux-pagination\" *ngIf=\"showPagination\">\n <ng-container *ngIf=\"!hidePrevious\">\n <a\n luxTooltip\n [content]=\"first\"\n placement=\"top\"\n delay=\"500\"\n (click)=\"onFirst()\"\n [ngClass]=\"{\n enabledFirstLast: !hidePrevious\n }\"\n class=\"button-pagination icon arrow-left-end\"\n ></a>\n <a\n luxTooltip\n [content]=\"previous\"\n placement=\"top\"\n delay=\"500\"\n (click)=\"onPrevious()\"\n [ngClass]=\"{\n enabledFirstLast: !hidePrevious\n }\"\n class=\"button-pagination icon arrow-left\"\n ></a>\n </ng-container>\n\n <span class=\"ellipsis\" *ngIf=\"displayPreviousEllipsis\">...</span>\n\n <ng-container *ngFor=\"let pageNum of pages\">\n <a\n luxTooltip\n content=\"{{ pageNum + 1 }}\"\n placement=\"top\"\n delay=\"500\"\n [ngClass]=\"{\n disabled: pageNum === paginationInfo.page,\n enabled: pageNum !== paginationInfo.page\n }\"\n class=\"button-pagination\"\n (click)=\"onPage(pageNum)\"\n >{{ pageNum + 1 }}</a\n >\n </ng-container>\n\n <span class=\"ellipsis\" *ngIf=\"displayNextEllipsis\">...</span>\n\n <ng-container *ngIf=\"!lastPage\">\n <a\n luxTooltip\n [content]=\"next\"\n placement=\"top\"\n delay=\"500\"\n (click)=\"onNext()\"\n [ngClass]=\"{\n enabledFirstLast: !lastPage\n }\"\n class=\"button-pagination icon arrow-right\"\n ></a>\n <a\n luxTooltip\n [content]=\"last\"\n placement=\"top\"\n delay=\"500\"\n (click)=\"onLast()\"\n [ngClass]=\"{\n enabledFirstLast: !lastPage\n }\"\n class=\"button-pagination icon arrow-right-end\"\n ></a>\n </ng-container>\n</div>\n",
4144
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}.lux-pagination{display:flex;flex-direction:row;margin:2% 0;width:100%;background:white;align-items:center}.disabled{cursor:not-allowed;border:1px solid #325c81;border:var(--lux-pagination-disabled-border, 1px solid #325c81);border-radius:10%;border-radius:var(--lux-pagination-disabled-border-radius, 10%);padding:1%;margin:0 .7%;color:#fff;color:var(--lux-pagination-disabled-color, white);background-color:#325c81;background-color:var(--lux-pagination-disabled-background-color, #325c81);text-decoration:none;pointer-events:none}.enabled{border:1px solid #cfcfcf;border:var(--lux-pagination-enabled-border, 1px solid #cfcfcf);border-radius:10%;border-radius:var(--lux-pagination-enabled-border-radius, 10%);padding:1%;margin:0 .7%;color:#325c81;color:var(--lux-pagination-enabled-color, #325c81);width:-webkit-min-content;width:-moz-min-content;width:min-content;cursor:pointer}.enabledFirstLast{border:1px solid #cfcfcf;border-radius:10%;padding:1%;color:#325c81;margin:0 .7%;width:-webkit-min-content;width:-moz-min-content;width:min-content;cursor:pointer}.ellipsis{margin:0 .5rem;padding:0;color:#325c81;width:-webkit-min-content;width:-moz-min-content;width:min-content}.button-pagination{width:1em;width:var(--lux-pagination-button-width, 1em);height:1.2em;height:var(--lux-pagination-button-height, 1.2em);font-size:80%;font-size:var(--lux-pagination-font-size, 80%);text-align:center}.icon{background-size:1.3em 1.4em;background-position:center;background-repeat:no-repeat}.arrow-right{background-image:url(\"data:image/svg+xml,%3Csvg width%3D%2268%22 height%3D%2248%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg%3E %3Ctitle%3Ebackground%3C%2Ftitle%3E %3Crect fill%3D%22none%22 id%3D%22canvas_background%22 height%3D%22402%22 width%3D%221082%22 y%3D%22-1%22 x%3D%22-1%22%2F%3E %3C%2Fg%3E %3Cg%3E %3Ctitle%3ELayer 1%3C%2Ftitle%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_2%22 points%3D%2221.8%2C45.7 10.4%2C44.3 30.8%2C24 10.4%2C3.7 21.8%2C2.3 43.5%2C24 %22%2F%3E %3C%2Fg%3E%3C%2Fsvg%3E\");background-position:.4em}.arrow-left{background-image:url(\"data:image/svg+xml,%3Csvg width%3D%2268%22 height%3D%2248%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg%3E %3Ctitle%3Ebackground%3C%2Ftitle%3E %3Crect fill%3D%22none%22 id%3D%22canvas_background%22 height%3D%22402%22 width%3D%221082%22 y%3D%22-1%22 x%3D%22-1%22%2F%3E %3C%2Fg%3E %3Cg%3E %3Ctitle%3ELayer 1%3C%2Ftitle%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_2%22 points%3D%2221.8%2C45.7 10.4%2C44.3 30.8%2C24 10.4%2C3.7 21.8%2C2.3 43.5%2C24 %22%2F%3E %3C%2Fg%3E%3C%2Fsvg%3E\");transform:rotate(180deg);background-position:.4em}.arrow-right-end{background-image:url(\"data:image/svg+xml,%3Csvg width%3D%2268%22 height%3D%2248%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg%3E %3Ctitle%3Ebackground%3C%2Ftitle%3E %3Crect fill%3D%22none%22 id%3D%22canvas_background%22 height%3D%22402%22 width%3D%221082%22 y%3D%22-1%22 x%3D%22-1%22%2F%3E %3C%2Fg%3E %3Cg%3E %3Ctitle%3ELayer 1%3C%2Ftitle%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_2%22 points%3D%2221.8%2C45.7 10.4%2C44.3 30.8%2C24 10.4%2C3.7 21.8%2C2.3 43.5%2C24 %22%2F%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_3%22 points%3D%2241.8%2C45.7 30.4%2C44.3 50.8%2C24 30.4%2C3.7 41.8%2C2.3 63.5%2C24 %22%2F%3E %3C%2Fg%3E%3C%2Fsvg%3E\");background-position:.1em}.arrow-left-end{background-image:url(\"data:image/svg+xml,%3Csvg width%3D%2268%22 height%3D%2248%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg%3E %3Ctitle%3Ebackground%3C%2Ftitle%3E %3Crect fill%3D%22none%22 id%3D%22canvas_background%22 height%3D%22402%22 width%3D%221082%22 y%3D%22-1%22 x%3D%22-1%22%2F%3E %3C%2Fg%3E %3Cg%3E %3Ctitle%3ELayer 1%3C%2Ftitle%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_2%22 points%3D%2221.8%2C45.7 10.4%2C44.3 30.8%2C24 10.4%2C3.7 21.8%2C2.3 43.5%2C24 %22%2F%3E %3Cpolygon fill%3D%22%23325C81%22 id%3D%22svg_3%22 points%3D%2241.8%2C45.7 30.4%2C44.3 50.8%2C24 30.4%2C3.7 41.8%2C2.3 63.5%2C24 %22%2F%3E %3C%2Fg%3E%3C%2Fsvg%3E\");background-position:.1em;transform:rotate(180deg)}@media only screen and (min-width: 300px) and (max-width: 500px){.arrow-right{background-position:.2em}.arrow-left{background-position:.2em}.arrow-right-end{background-position:0em}.arrow-left-end{background-position:0em}}@media only screen and (min-width: 500px) and (max-width: 850px){.arrow-right{background-position:.3em}.arrow-left{background-position:.3em}.arrow-right-end{background-position:0em}.arrow-left-end{background-position:0em}}@media only screen and (min-width: 900px){.arrow-right{background-position:.2em}.arrow-left{background-position:.2em}.arrow-right-end{background-position:0em}.arrow-left-end{background-position:0em}}\n"]
4145
- },] }
4146
- ];
4147
- PaginationComponent.ctorParameters = function () { return []; };
4148
- PaginationComponent.propDecorators = {
4149
- goToPage: [{ type: i0.Output }],
4150
- pageSizeChange: [{ type: i0.Output }],
4151
- lang: [{ type: i0.Input }],
4152
- paginationInfo: [{ type: i0.Input }]
4153
- };
4154
-
4155
- var RadiogroupComponent = /** @class */ (function () {
4156
- function RadiogroupComponent() {
4157
- this.touched = false;
4158
- this.name = 'radiogroup1';
4159
- this.disabled = false;
4160
- this.readonly = false;
4161
- this.required = false;
4162
- this.itemsChange = new i0.EventEmitter();
4163
- this.valueChange = new i0.EventEmitter();
4164
- this._value = undefined;
4165
- this._items = [];
4166
- // ControlValueAccessor Interface
4167
- this.onChange = function (value) { };
4168
- this.onTouched = function () { };
4169
- }
4170
- Object.defineProperty(RadiogroupComponent.prototype, "items", {
4171
- get: function () {
4172
- return this._items;
4173
- },
4174
- set: function (col) {
4175
- var _this = this;
4176
- this._items = (col || []).map(function (it, index) { return _this.ensureHasUniqueName(it, index); });
4177
- this.itemsChange.emit(col);
4178
- },
4179
- enumerable: false,
4180
- configurable: true
4181
- });
4182
- Object.defineProperty(RadiogroupComponent.prototype, "value", {
4183
- get: function () {
4184
- return this._value;
4185
- },
4186
- set: function (v) {
4187
- if (v === this._value) {
4188
- return;
4189
- }
4190
- var initialAndEmpty = isInitialAndEmpty(this._value, v);
4191
- this._value = v;
4192
- this.onChange(v);
4193
- if (!initialAndEmpty) {
4194
- this.valueChange.emit(v);
4195
- }
4196
- },
4197
- enumerable: false,
4198
- configurable: true
4199
- });
4200
- RadiogroupComponent.prototype.writeValue = function (value) {
4201
- this.value = value;
4202
- };
4203
- RadiogroupComponent.prototype.registerOnChange = function (onChange) {
4204
- this.onChange = onChange;
4205
- };
4206
- RadiogroupComponent.prototype.registerOnTouched = function (onTouched) {
4207
- this.onTouched = onTouched;
4208
- };
4209
- RadiogroupComponent.prototype.markAsTouched = function () {
4210
- if (!this.touched) {
4211
- this.onTouched();
4212
- this.touched = true;
4213
- }
4214
- };
4215
- RadiogroupComponent.prototype.setDisabledState = function (disabled) {
4216
- this.disabled = disabled;
4217
- };
4218
- // End ControlValueAccessor Interface
4219
- // Validator interface
4220
- RadiogroupComponent.prototype.registerOnValidatorChange = function () { };
4221
- RadiogroupComponent.prototype.validate = function (control) {
4222
- var value = control.value;
4223
- if (this.required &&
4224
- (value === '' || value === null || value === undefined)) {
4225
- return { required: { value: value, reason: 'Required field.' } };
4226
- }
4227
- return null;
4228
- };
4229
- // End of Validator interface
4230
- RadiogroupComponent.prototype.setValue = function (event, item) {
4231
- if (!this.disabled && !this.readonly) {
4232
- this.value = item.value;
4233
- this.markAsTouched();
4234
- }
4235
- event.preventDefault();
4236
- };
4237
- RadiogroupComponent.prototype.ensureHasUniqueName = function (item, index) {
4238
- if (!item.name) {
4239
- item.name = this.name + "_" + index;
4240
- }
4241
- return item;
4242
- };
4243
- return RadiogroupComponent;
4244
- }());
4245
- RadiogroupComponent.decorators = [
4246
- { type: i0.Component, args: [{
4247
- selector: 'lux-radiogroup',
4248
- template: "<div class=\"radiogroup\"\n [class.disabled]=\"disabled || readonly\"\n >\n <ng-container *ngFor=\"let item of items; let first=first; let last=last\">\n <div [class.radio-start]=\"first\"\n [class.radio-end]=\"last\"\n class=\"radio-item\"\n [class.selected]=\"item.value === value\"\n (click)=\"setValue($event, item)\"\n >\n <input [id]=\"item.name\"\n type=\"radio\"\n [name]=\"name\"\n [attr.disabled]=\"disabled || null\"\n [attr.readonly]=\"readonly || null\"\n [value]=\"item.value\">\n <label [for]=\"item.name\"\n class=\"unselectable\"\n >{{ item.label }}</label>\n </div>\n</ng-container>\n</div>\n",
4249
- providers: [
4250
- {
4251
- provide: forms.NG_VALUE_ACCESSOR,
4252
- multi: true,
4253
- useExisting: i0.forwardRef(function () { return RadiogroupComponent; })
4254
- },
4255
- {
4256
- provide: forms.NG_VALIDATORS,
4257
- multi: true,
4258
- useExisting: i0.forwardRef(function () { return RadiogroupComponent; })
4259
- }
4260
- ],
4261
- styles: [":focus{z-index:1}input,select,textarea{border:solid 1px #495057;border:solid 1px var(--lux-input-border-color, #495057);margin:0;margin:var(--lux-input-margin, 0rem);padding:0 .5rem;padding:var(--lux-input-padding, 0rem .5rem)}.alert{padding:.2rem 2rem;background:#fe2e2e;background:var(--lux-alert-background, #fe2e2e);color:#fff;color:var(--lux-alert-color, white);font-family:Consolas,monospace;width:45%;margin-right:1rem;display:inline-block}.symbol{display:inline-block;align-items:baseline;padding:0 .5rem;margin-bottom:0;font-weight:400;color:default;color:var(--lux-symbol-color, default);text-align:center;white-space:nowrap;background:default;background:var(--lux-symbol-background, default);border:1px solid #495057;border:1px solid var(--lux-input-border-color, #495057);font-size:1rem;font-size:var(--lux-symbol-font-size, 1rem)}.rounded,.rounded-right,.rounded-middle,.rounded-left{border-radius:.25rem;border:1px solid;border:var(--lux-input-border, 1px solid)}.rounded-left{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-middle{border-radius:0}.rounded-right{border-top-left-radius:0;border-bottom-left-radius:0}.prefix{border-right:none}.infix{border-left:none;border-right:none}.postfix{border-left:none}.radiogroup{display:flex}.radio-item{border-radius:0;border:1px solid #ccc;padding:0 .5rem;padding:var(--lux-radiogroup-padding, 0rem .5rem)}.radio-item input{display:none}.radio-item label{color:initial;color:var(--lux-radiogroup-color, initial);font-size:initial;font-size:var(--lux-radiogroup-font-size, initial);margin-top:.3rem;margin-bottom:.3rem}.radio-item.selected{background-color:#2e2eac;background-color:var(--lux-radiogroup-selected-background-color, #2e2eac)}.radio-item.selected label{font-size:initial;font-size:var(--lux-radiogroup-font-size, initial);color:#fff;color:var(--lux-radiogroup-selected-color, white)}.radio-start{border-top-left-radius:.5rem;border-bottom-left-radius:.5rem}.radio-end{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.disabled .radio-item{background-color:#f0f0f0;color:#444}.disabled .selected{font-size:initial;font-size:var(--lux-radiogroup-selected-disabled-font-size, initial);color:#fff;color:var(--lux-radiogroup-selected-disabled-color, white);background-color:#9898ec;background-color:var(--lux-radiogroup-selected-disabled-background-color, #9898ec)}.unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}\n"]
4262
- },] }
4263
- ];
4264
- RadiogroupComponent.ctorParameters = function () { return []; };
4265
- RadiogroupComponent.propDecorators = {
4266
- name: [{ type: i0.Input }],
4267
- disabled: [{ type: i0.Input }],
4268
- readonly: [{ type: i0.Input }],
4269
- required: [{ type: i0.Input }],
4270
- items: [{ type: i0.Input }],
4271
- itemsChange: [{ type: i0.Output }],
4272
- value: [{ type: i0.Input }],
4273
- valueChange: [{ type: i0.Output }]
4274
- };
4275
-
4276
- var sequencer = 0;
4277
- var SelectComponent = /** @class */ (function () {
4278
- function SelectComponent() {
4279
- this.id = 'stringList' + sequencer++;
4280
- this.disabled = false;
4281
- this.required = false;
4282
- /** Allow multiple elements */
4283
- this.multiple = true;
4284
- this.value = [];
4285
- this.valueChange = new i0.EventEmitter();
4286
- this.placeholder = 'Add new';
4287
- /** If set, check there is no duplicates in the data. */
4288
- this.unique = true;
4289
- /** Validation function for new items. Returns error or null if valid */
4290
- this.validateItem = function (_) { return null; };
4291
- this.newEntry = '';
4292
- this.error = null;
4293
- this.isValidNewEntry = false;
4294
- this.touched = false;
4295
- // ControlValueAccessor Interface
4296
- this.onChange = function (value) { };
4297
- this.onTouched = function () { };
4298
- }
4299
- SelectComponent.prototype.writeValue = function (value) {
4300
- this.value = value;
4301
- };
4302
- SelectComponent.prototype.registerOnChange = function (onChange) {
4303
- this.onChange = onChange;
4304
- };
4305
- SelectComponent.prototype.registerOnTouched = function (onTouched) {
4306
- this.onTouched = onTouched;
4307
- };
4308
- SelectComponent.prototype.markAsTouched = function () {
4309
- if (!this.touched) {
4310
- this.onTouched();
4311
- this.touched = true;
4312
- }
4313
- };
4314
- SelectComponent.prototype.setDisabledState = function (disabled) {
4315
- this.disabled = disabled;
4316
- };
4317
- // End ControlValueAccessor Interface
4318
- // Validator interface
4319
- SelectComponent.prototype.registerOnValidatorChange = function () { };
4320
- SelectComponent.prototype.validate = function (control) {
4321
- var value = control.value;
4322
- if (this.required &&
4323
- (value === '' || value === null || value === undefined)) {
4324
- return { required: { value: value, reason: 'Required field.' } };
4325
- }
4326
- return null;
4327
- };
4328
- Object.defineProperty(SelectComponent.prototype, "canAdd", {
4329
- // End of Validator interface
4330
- get: function () {
4331
- return this.multiple || this.value.length === 0;
4332
- },
4333
- enumerable: false,
4334
- configurable: true
4335
- });
4336
- SelectComponent.prototype.add = function (val) {
4337
- this.value.push(val);
4338
- this.newEntry = '';
4339
- this.markAsTouched();
4340
- this.valueChange.emit(this.value);
4341
- };
4342
- SelectComponent.prototype.remove = function (index) {
4343
- if (this.value.length > index) {
4344
- this.value.splice(index, 1);
4345
- this.markAsTouched();
4346
- this.valueChange.emit(this.value);
4347
- }
4348
- };
4349
- SelectComponent.prototype.onKeyPress = function (event) {
4350
- if (event.key === 'Enter' && !this.error && this.newEntry !== '') {
4351
- // Add on pressing Enter/Return
4352
- this.markAsTouched();
4353
- this.add(this.newEntry);
4354
- }
4355
- };
4356
- SelectComponent.prototype.onChangeNewEntry = function (newValue) {
4357
- this.markAsTouched();
4358
- if (!newValue) {
4359
- this.isValidNewEntry = false;
4360
- this.error = null;
4361
- return;
4362
- }
4363
- if (this.unique) {
4364
- var found = (this.value || []).find(function (it) { return it === newValue; });
4365
- this.isValidNewEntry = !found;
4366
- this.error = found
4367
- ? "Value '" + newValue + "' is already in. Cannot add duplicates."
4368
- : null;
4369
- if (!this.isValidNewEntry) {
4370
- return;
4371
- }
4372
- }
4373
- this.error = this.validateItem(newValue);
4374
- this.isValidNewEntry = !this.error;
4375
- };
4376
- return SelectComponent;
4377
- }());
4378
- SelectComponent.decorators = [
4379
- { type: i0.Component, args: [{
4380
- selector: 'lux-select',
4381
- template: "<div class=\"lux-select\">\n <ul class=\"list\">\n <li *ngFor=\"let item of value; let i = index\">\n <span>{{ item }}</span>\n <button *ngIf=\"!disabled\"\n class=\"remove\"\n (click)=\"remove(i)\"\n [attr.aria-label]=\"'Remove ' + item\"\n >Remove</button>\n </li>\n </ul>\n <div class=\"add-new-item\" *ngIf=\"!disabled\">\n <lux-input\n id=\"{{ id + 'addNew' }}\"\n type=\"string\"\n [placeholder]=\"placeholder\"\n [attr.aria-label]=\"placeholder\"\n [disabled]=\"disabled\"\n [(value)]=\"newEntry\"\n (keyPress)=\"onKeyPress($event)\"\n (valueChange)=\"onChangeNewEntry($event)\"\n >\n </lux-input>\n <div *ngIf=\"canAdd\">\n <button *ngIf=\"isValidNewEntry\" (click)=\"add(newEntry)\">Add</button>\n </div>\n <div class=\"error\">\n {{ error }}\n </div>\n </div>\n</div>\n",
4382
- providers: [
4383
- {
4384
- provide: forms.NG_VALUE_ACCESSOR,
4385
- multi: true,
4386
- useExisting: i0.forwardRef(function () { return SelectComponent; })
4387
- },
4388
- {
4389
- provide: forms.NG_VALIDATORS,
4390
- multi: true,
4391
- useExisting: i0.forwardRef(function () { return SelectComponent; })
4392
- }
4393
- ],
4394
- styles: [".lux-select{margin-bottom:.5em}.lux-select .list{margin:1em;padding-bottom:.2em;list-style-type:square}.lux-select .list span{margin-bottom:.3em}.remove{margin-left:2em;font-size:.65em;color:#b22222;background:transparent;border:2px solid #BBB}.add-new-item{display:inline-flex;margin-left:2.2em;height:1.6em}.error{margin:.5em 0;color:#b22222}\n"]
4395
- },] }
4396
- ];
4397
- SelectComponent.ctorParameters = function () { return []; };
4398
- SelectComponent.propDecorators = {
4399
- id: [{ type: i0.Input }],
4400
- disabled: [{ type: i0.Input }],
4401
- required: [{ type: i0.Input }],
4402
- multiple: [{ type: i0.Input }],
4403
- value: [{ type: i0.Input }],
4404
- valueChange: [{ type: i0.Output }],
4405
- placeholder: [{ type: i0.Input }],
4406
- unique: [{ type: i0.Input }],
4407
- validateItem: [{ type: i0.Input }]
4408
- };
4409
-
4410
- var VoiceRecognitionDirective = /** @class */ (function () {
4411
- function VoiceRecognitionDirective(el, renderer) {
4412
- this.el = el;
4413
- this.renderer = renderer;
4414
- this.isRecognizing = false;
4415
- var speechRecognition = window.webkitSpeechRecognition;
4416
- if (speechRecognition) {
4417
- this.recognition = new speechRecognition();
4418
- }
4419
- }
4420
- VoiceRecognitionDirective.prototype.ngOnInit = function () {
4421
- var _this = this;
4422
- if (this.recognition) {
4423
- // API is available
4424
- this.recognition.lang = this.language || window.navigator.language;
4425
- this.recognition.interimResults = false;
4426
- this.recognition.maxAlternatives = 1;
4427
- // Add mic icon
4428
- this.mic = document.createElement('div');
4429
- this.mic.setAttribute('class', 'lux-microphone');
4430
- var parent = this.el.nativeElement.parentElement;
4431
- parent.appendChild(this.mic);
4432
- // Add event handlers
4433
- this.mic.onclick = function () { return _this.microphoneClick(); };
4434
- this.recognition.onresult = function (event) { return _this.onRecognized(event); };
4435
- }
4436
- };
4437
- VoiceRecognitionDirective.prototype.microphoneClick = function () {
4438
- if (this.isRecognizing) {
4439
- // stop
4440
- this.isRecognizing = false;
4441
- this.renderer.removeClass(this.mic, 'lux-recording');
4442
- this.recognition.abort();
4443
- }
4444
- else {
4445
- // start
4446
- this.el.nativeElement.value = getRecordingMessage(this.language);
4447
- this.isRecognizing = true;
4448
- this.renderer.addClass(this.mic, 'lux-recording');
4449
- this.recognition.start();
4450
- }
4451
- };
4452
- VoiceRecognitionDirective.prototype.onRecognized = function (event) {
4453
- var recognizedText = event.results[0][0].transcript;
4454
- this.isRecognizing = false;
4455
- this.el.nativeElement.value = recognizedText;
4456
- this.renderer.removeClass(this.mic, 'lux-recording');
4457
- };
4458
- return VoiceRecognitionDirective;
4459
- }());
4460
- VoiceRecognitionDirective.decorators = [
4461
- { type: i0.Directive, args: [{
4462
- selector: '[luxVoiceRecognition]'
4463
- },] }
4464
- ];
4465
- VoiceRecognitionDirective.ctorParameters = function () { return [
4466
- { type: i0.ElementRef },
4467
- { type: i0.Renderer2 }
4468
- ]; };
4469
- VoiceRecognitionDirective.propDecorators = {
4470
- language: [{ type: i0.Input }]
4471
- };
4472
- var getRecordingMessage = function (lang) {
4473
- switch (lang.toLowerCase()) {
4474
- case 'es':
4475
- case 'es-es':
4476
- return 'Grabando...';
4477
- case 'en':
4478
- case 'en-uk':
4479
- case 'en-us':
4480
- default:
4481
- return 'Recording...';
4482
- }
4483
- };
4484
- var ɵ0 = getRecordingMessage;
4485
-
4486
- /* Create a new injection token for injecting the window into a component. */
4487
- var WINDOW = new i0.InjectionToken('WindowToken');
4488
- /* Define abstract class for obtaining reference to the global window object. */
4489
- var WindowRef = /** @class */ (function () {
4490
- function WindowRef() {
4491
- }
4492
- Object.defineProperty(WindowRef.prototype, "nativeWindow", {
4493
- // eslint-disable-next-line @typescript-eslint/ban-types
4494
- get: function () {
4495
- throw new Error('Not implemented.');
4496
- },
4497
- enumerable: false,
4498
- configurable: true
4499
- });
4500
- return WindowRef;
4501
- }());
4502
- /* Define class that implements the abstract class and returns the native window object. */
4503
- var BrowserWindowRef = /** @class */ (function (_super) {
4504
- __extends(BrowserWindowRef, _super);
4505
- function BrowserWindowRef() {
4506
- return _super.call(this) || this;
4507
- }
4508
- Object.defineProperty(BrowserWindowRef.prototype, "nativeWindow", {
4509
- // eslint-disable-next-line @typescript-eslint/ban-types
4510
- get: function () {
4511
- return window;
4512
- },
4513
- enumerable: false,
4514
- configurable: true
4515
- });
4516
- return BrowserWindowRef;
4517
- }(WindowRef));
4518
- /* Create an factory function that returns the native window object. */
4519
- // eslint-disable-next-line @typescript-eslint/ban-types
4520
- var windowFactory = function (browserWindowRef, platformId) {
4521
- if (i1.isPlatformBrowser(platformId)) {
4522
- return browserWindowRef.nativeWindow;
4523
- }
4524
- return new Object();
4525
- };
4526
- /* Create a injectable provider for the WindowRef token that uses the BrowserWindowRef class. */
4527
- var browserWindowProvider = {
4528
- provide: WindowRef,
4529
- useClass: BrowserWindowRef
4530
- };
4531
- /* Create an injectable provider that uses the windowFactory function for returning the native window object. */
4532
- var windowProvider = {
4533
- provide: WINDOW,
4534
- useFactory: windowFactory,
4535
- deps: [WindowRef, i0.PLATFORM_ID]
4536
- };
4537
- /* Create an array of providers. */
4538
- var WINDOW_PROVIDERS = [
4539
- browserWindowProvider,
4540
- windowProvider
4541
- ];
4542
-
4543
- var LuxModule = /** @class */ (function () {
4544
- function LuxModule() {
4545
- }
4546
- return LuxModule;
4547
- }());
4548
- LuxModule.decorators = [
4549
- { type: i0.NgModule, args: [{
4550
- declarations: [
4551
- AutocompleteComponent,
4552
- AutocompleteListComponent,
4553
- FilterComponent,
4554
- CheckboxComponent,
4555
- DatetimeComponent,
4556
- InputComponent,
4557
- GeolocationComponent,
4558
- LuxTooltipDirective,
4559
- LuxModalWindowComponent,
4560
- LuxModalBackdropComponent,
4561
- LuxBreadcrumbComponent,
4562
- MapComponent,
4563
- SelectComponent,
4564
- TooltipComponent,
4565
- PaginationComponent,
4566
- RadiogroupComponent,
4567
- VoiceRecognitionDirective
4568
- ],
4569
- entryComponents: [
4570
- LuxModalWindowComponent,
4571
- LuxModalBackdropComponent,
4572
- TooltipComponent
4573
- ],
4574
- providers: [ModalService, TooltipService, WINDOW_PROVIDERS],
4575
- imports: [
4576
- angularResizeEvent.AngularResizedEventModule,
4577
- forms.FormsModule,
4578
- i1$1.HttpClientModule,
4579
- forms.ReactiveFormsModule,
4580
- router.RouterModule,
4581
- i1.CommonModule
4582
- ],
4583
- exports: [
4584
- AutocompleteComponent,
4585
- AutocompleteListComponent,
4586
- FilterComponent,
4587
- CheckboxComponent,
4588
- DatetimeComponent,
4589
- InputComponent,
4590
- GeolocationComponent,
4591
- LuxTooltipDirective,
4592
- LuxBreadcrumbComponent,
4593
- LuxBreadcrumbComponent,
4594
- MapComponent,
4595
- SelectComponent,
4596
- PaginationComponent,
4597
- RadiogroupComponent,
4598
- VoiceRecognitionDirective
4599
- ]
4600
- },] }
4601
- ];
4602
-
4603
- /*
4604
- * Public API Surface of lux
4605
- */
4606
-
4607
- /**
4608
- * Generated bundle index. Do not edit.
4609
- */
4610
-
4611
- exports.AutocompleteComponent = AutocompleteComponent;
4612
- exports.AutocompleteListComponent = AutocompleteListComponent;
4613
- exports.CheckboxComponent = CheckboxComponent;
4614
- exports.FilterComponent = FilterComponent;
4615
- exports.InputComponent = InputComponent;
4616
- exports.LuxBreadcrumbComponent = LuxBreadcrumbComponent;
4617
- exports.LuxModule = LuxModule;
4618
- exports.LuxTooltipDirective = LuxTooltipDirective;
4619
- exports.ModalRef = ModalRef;
4620
- exports.ModalService = ModalService;
4621
- exports.PaginationComponent = PaginationComponent;
4622
- exports.RadiogroupComponent = RadiogroupComponent;
4623
- exports["ɵa"] = DatetimeComponent;
4624
- exports["ɵb"] = RegexpService;
4625
- exports["ɵc"] = GeolocationComponent;
4626
- exports["ɵd"] = ModalStack;
4627
- exports["ɵe"] = LuxModalConfig;
4628
- exports["ɵf"] = GeolocationService;
4629
- exports["ɵg"] = TooltipService;
4630
- exports["ɵh"] = LuxModalWindowComponent;
4631
- exports["ɵi"] = LuxModalBackdropComponent;
4632
- exports["ɵj"] = MapComponent;
4633
- exports["ɵk"] = OpenLayerLoaderService;
4634
- exports["ɵl"] = SelectComponent;
4635
- exports["ɵm"] = TooltipComponent;
4636
- exports["ɵn"] = VoiceRecognitionDirective;
4637
- exports["ɵo"] = WINDOW;
4638
- exports["ɵp"] = WindowRef;
4639
- exports["ɵq"] = BrowserWindowRef;
4640
- exports["ɵr"] = windowFactory;
4641
- exports["ɵs"] = WINDOW_PROVIDERS;
4642
- exports["ɵt"] = ContentRef;
4643
-
4644
- Object.defineProperty(exports, '__esModule', { value: true });
4645
-
4646
- }));
4647
- //# sourceMappingURL=metadev-lux.umd.js.map