@metadev/lux 0.18.0 → 0.20.0

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