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